您的位置:首页 > Web前端 > CSS

CSS学习-1

2016-03-08 20:35 405 查看
/[b]**************************************************[/b]

本文叙述了CSS简介等基础知识

[b]*********************************************************[/b]/

一、CSS

CSS,Cascade Style Sheet。是用来装潢HTML网页的一门技术。

在HTML中引入CSS总共有3种方式:

1.外部样式表;

<head>
<title>css</title>
<!--在HTML文件引用文件名为index的css文件-->
<link href="index.css" rel="stylesheet" type="text/css" />
</head>


2.内部样式表;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>form标签实验</title>
<style type="text/css">
p{color:Red;}
</style>
</head>
<body>
<form name="text1" method="get" action="HTMLPage.htm"">
姓名:<input type="text" value="" size="15" maxlength="" /> <br />
年龄:<input type="text" value="18" size="3" maxlength="3" /> <br />
账号:<input type="text" value="" size="5" maxlength="" /> <br />
密码;<input type="password" value="" size="8" maxlength="" /><br />
<input type="radio" name="question1" value="boy" />男
<input type="radio" name="question1" value="girl" />女
<br />
<input type="radio" name="question2" value="80后"/>80后
<input type="radio" name="question2" valude="90后" />90后
<input type="radio" name="question2" valude="00后" />00后
<br />
</form>
<br />
<p>我爱学习</p>
<p>i love learn</p>
<p>藕断丝连</p>
</body>
</html>


效果:



值得注意的是p{}的定义要在style之间,但是sytle必须在head内。

3.内联样式表。

CSS样式不是在style之间定义,而是在style属性中定义

案例:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>form标签实验</title>
<style type="text/css">
p{color:Red;}
</style>
</head>
<body>
<form name="text1" method="get" action="HTMLPage.htm"">
姓名:<input type="text" value="" size="15" maxlength="" /> <br />
年龄:<input type="text" value="18" size="3" maxlength="3" /> <br />
账号:<input type="text" value="" size="5" maxlength="" /> <br />
密码;<input type="password" value="" size="8" maxlength="" /><br />
<input type="radio" name="question1" value="boy" />男
<input type="radio" name="question1" value="girl" />女
<br />
<input type="radio" name="question2" value="80后"/>80后
<input type="radio" name="question2" valude="90后" />90后
<input type="radio" name="question2" valude="00后" />00后
<br />
</form>
<br />
<p>我爱学习</p>
<p>i love learn</p>
<p>藕断丝连</p>
<!--内联式样式表-->
<p style="color;Red;">我爱学习</p>
<p style="color:Blue;">i love learn</p>
<p style="color:Green;">藕断丝连</p>
</body>
</html>


效果图:



注意:小批量代码可以用内部样式表,大规模必须采用外部样式表,内联方式只是 用于微调情况。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: