css 层叠样式表
作用:是给HTML标记添加各种表现形式,比如文本样式、背景颜色、背景图片。
css语法格式
<html>
<head>
<style type=“text/css>
标签名称{
属性:属性值; <---用分号隔开
}
</style>
</head>
<body>
</body>
</html>
html的注释是<!-- XXX -->
css 的注释 /* XXXX */
选择器
1·基本选择器:
*
{
color:red;
}
2·标签选择器:
h1
{
color:red;
}
3·id选择器
#myid
{
color: yellow;
}
标签属性 id=“myid”
4·class选择器(又名 类选择器)
.myclass
{
color: rgb(170, 47, 9);
}
标签属性 class=“myclass”
常用的属性
-
height 高度
-
width宽度
一般标签都会使用的两个属性
字体属性
-
font-size:文字大小,px
-
font-family:字体类型
-
font-style:斜体
-
font-weight: 粗体 取值bold。
css边框属性
使用div为例
-
width:宽度
-
heigh:高度
-
border-top:上边框
-
border-bottom:下边框
-
border-left:左边框
-
border-right:右边框
边框的类型
-
none(无边框)
-
solid(实线)
-
dashed(虚线)
-
dotted(点状线)
-
css指定外边框
-
margin=left:外边框的左边
-
margin-top:外边框的上
-
margin-right:外边框的右边距
-
margin-botto:外边框的下边距
css指定内边框
-
padding-left: 80px; 内边框的左边距
-
padding-top: 249px;内边框的上
-
padding-bottom: 30px;内边框的下
-
padding-right: 200px;内边框的右