块级元素和行内元素分别有哪些?动手测试并列出4条以上的特性区别
-
Block level(块级元素)
- div h1 h2 h3 h4 h5 h6 p hr
form ul dl ol pre table
li dd dt tr td th
- div h1 h2 h3 h4 h5 h6 p hr
-
inline level(行内元素)
- em strong span a br img
button iput label select textarea
code script
- em strong span a br img
什么是 CSS 继承? 哪些属性能继承,哪些不能?
- css继承:设置父级元素,其子级元素的样式会和父级元素一样。
- 能继承的元素:letter-spacing、word-spacing、white-space、line-height、color、font、font-family、font-size、font-style、font-variant、font-weight、text-decoration、text-transform、direction、list-style、list-style-type、list-style-position、list-style-image、text-indent和text-align
- 不能继承:display、margin、border、padding、background、height、min-height、max-height、width、min-width、max-width、overflow、position、left、right、top、bottom、z-index、float、clear、table-layout、vertical-align、page-break-after、page-bread-before和unicode-bidi。
如何让块级元素水平居中?如何让行内元素水平居中?
- 块级元素居中语法:margin:0 auto;行内元素水平居中:text-align:center;
用 CSS 实现一个三角形
<div class="triangle"></div>
.triangle{
width:0;
height:0;
border-left:20px solid transparent;
border-right:20px solid transparent;
border-bottom:20px solid blue;
}
单行文本溢出加 ...如何实现?
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
px, em, rem 有什么区别?
- px:固定尺寸
- em:相对于父元素的尺寸倍数
- rem:相对于根元素(body)的尺寸倍数
解释下面代码的作用?为什么要加引号? 字体里\5b8b\4f53代表什么?
body{
font: 12px/1.5 tahoma,arial,'Hiragino Sans GB','\5b8b\4f53',sans-serif;
}
表示字体规格为:
字体大小为12px
字体行高为1.5倍字体大小
字体可在tahoma,arial,'Hiragino Sans GB','\5b8b\4f53',sans-serif 这些字体中选择(若都不存在,则为浏览器默认字体)
当有空格或者Unicode码时,需要加引号
\5b8b\4f53是字体的Unicode码,表示黑体
CSS简单样式
9/18/2017