• 修改列表样式
/*去掉默认的符号。这个常用*/ ul, ol { list-style: none; } /*列表方形符号*/ ul { list-style: square; } /*符号在盒模型内*/ ul { list-style: inside; /*outside*/ 以前面那个点开始计算,也就是序号 } /*可以用图形符号*/ ul { list-style: url(https://i.loli.net/2019/11/08/4vriKTQR6sXnFBW.png) }默认情况下,背景区域覆盖内容+内边距+边框
控制背景图片的重复方式
background-repeat: no-repeat; 不重复background-repeat: repeat; 水平和垂直都重复background-repeat: repeat-x; 水平重复background-repeat: repeat-y; 垂直重复• 属性合并简写 • 多重背景
.box{ background: #ccc url(images/bg.png) center no-repeat; } .box{ background: #ccc url(images/bg.png) center no-repeat, #ccc url(images/bg2.png) 20px 20px no-repeat; }小练习 • 使用background实现如下效果 ü http://js.jirengu.com/rifur
• 推荐资源
图床 https://sm.ms图片Sprites https://csssprites.com图片压缩 https://tinypng.com/• 用法
border: 1px solid red; • solid 实线 • dotted 点线 • dashed 虚线 .list { border: 1px solid #ddd; } .list > .item { border-bottom: 1px solid #ddd; /* 下边框 */ }• border应用
实现三角形 .box { width: 0; height: 0; border: 50px solid transparent; border-radius: 50%; border-top-color: red; } 实现半圆 .box { width: 0; height: 0; border: 50px solid transparent; border-radius: 50%; border-top-color: red; border-right-color: red; }• border应用
实现三角形 .box { width: 0; height: 0; border: 50px solid transparent; border-top-color: red; } 实现椭圆 .box { width: 100px; height: 200px; background: red; border-radius: 50%; } 实现扇形 .box { width: 0; height: 0; border: 50px solid transparent; border-radius: 50%; border-top-color: red; } 实现半圆 .box { width: 0; height: 0; border: 50px solid transparent; border-radius: 50%; border-top-color: red; border-right-color: red; }• border-collapse
用于设置表格边框是分开还是合并。 • collapse 合并 • separate 分开 table { border-collapse: collapse; }行高 line-height • 设置行盒的高度
也就是一行文字占据的垂直空间• line-height: 1.5; 当前元素font-size的1.5倍。该倍数会继承给孩子。 推荐的用法。 • line-height: 20px; 占据高度固定值 • line-height: 150%; 当前元素font-size的1.5倍。会计算具体值,把具体值继承给孩子。
body { font: 14px/1.4 Arial; }注意:文字占据的高度不是由font-size决定的,而是由line-height决定的
vertical-align • 用处
设置inline、inline-block、table-cell元素垂直对齐方式父元素的基线由父元素最后一个行盒的基线决定,如果父亲为空那基线 就是下margin • baseline 使元素的基线与父元素的基线对齐 • middle 使元素的中部与父元素的基线加上父元素x高度的一半对 齐。 • top 使元素及其后代元素的顶部与整行的顶部对齐。 • bottom 使元素及其后代元素的底部与整行的底部对齐