1.CSS的布局常用样式属性
1)width 设置元素(标签)的宽度。如:width:100px;
2)height 设置元素(标签)的高度。如:height:200px;
3)background 设置元素背景颜色或背景图片。如:设置元素的背景色:background:black;设置元素的背景图片:background:url(imgs/logo.jpg);
4)border 设置元素四周的边框。如:设置元素四周边框是1像素宽的红色实线border:1px solid red;
也可以写作:
border-top 设置顶边边框。如borer-top:10px solid red;
border-bottom 设置底边边框。如border-bottom:10px solid blue;
border-left 设置左边边框。border-left:10px solid green;
border-right 设置右边边框。border-right:10px solid yellow。
5)padding设置元素包含的内容和元素的边框的距离,也叫内边距,如padding:20px;padding是同时设置四个边,也可以像border一样拆分成四条边:padding-top、padding-bottom、padding-left、padding-right。
6)margin 设置元素和外界的距离,也叫外边距,如margin:10px;也可如上margin-top、margin-bottom、margin-left、margin-right
7)float 设置元素浮动,浮动可以让块元素排列在一行,浮动分为左浮动:float:left;右浮动:float:right
2.CSS常用的文本样式属性
1)colo 设置文字的颜色。如:color:red;
2)font -size 设置文字的大小。如:font-size:12px;
3)font-family 设置文字的字体。如:font-family:‘Microsoft Yahei’;
4)line-weight 设置文字是否加粗。如:设置加粗:font-weight:bold;设置不加粗:font-family:normal;
5)line-height 设置文字的行高。如:表示文字高度加上文字上下的间距是24px,也就是每一行占有的高度是24px:line-height:24px;
6)text-decoration 设置文字的下划线。如:将文字下划线去掉:text-decoration:none;
7)text-align 设置文字水平对齐方式。如:设置文字水平居中:text-align:center;
8)text-indent 设置文字首行缩进。如:设置文字首行缩进24px:text-indent:24px。
CSS属性
最新推荐文章于 2022-11-10 11:19:11 发布