1.块级元素和行内元素分别有哪些?动手测试并列出4条以上的特性区别
块级元素有 div h1 h2 h3 h4 h5 h6 p hr form ul dl ol table li dd dt tr th td
行内块元素:em strong a br img button input label select textarea code script
特性(1)块级元素独占一行,行内元素和相邻的内联元素占一行
(2)块级元素可以包含行内元素和块级元素,行内元素不能包含块级别元素
(3)块级元素可以设置宽和高,但是行内元素是依据内部的内容撑开的,汗内元素的宽和高的设置是无效的
(4)同时margin和纵向的padding对于行内元素也是无效的,块级元素可以设置margin和padding
2.什么是 CSS 继承? 哪些属性能继承,哪些不能?
css继承如父元素设置了某种属性如color:white,但是子元素没有设置color的属性,然后子元素就会从父元素那里继承该属性
能继承的属性:
所有元素:visibility和cursor
内联元素可继承: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。
终端块状元素可继承:text-indent和text-align。
列表元素可继承:list-style、list-style-type、list-style-position、list-style-image。
表格元素可继承:border-collapse。
不能继承的:
不可继承的: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。
3.如何让块级元素水平居中?如何让行内元素水平居中?
3.1.行内或类行内元素(比如文本和链接)
在块级容器中让行内元素居中,用text-align:center;
(这中方法可以让 inline/inline-block/inline-table/flex)居中
3.2块级元素
设置margin:0 auto;
具体参考
https://www.w3cplus.com/css/centering-css-complete-guide.html
http://www.w3cplus.com/css/float-center.html
4.用 CSS 实现一个三角形
https://jsbin.com/fajabidogo/edit?html,css,output
5.单行文本溢出加...如何实现?
P{
white-space:nowrap;//文字不换行
overflow:hidden;//超出部分隐藏
text-overflow:ellipsis;//用。。代替多余的文字
}
6.px, em, rem 有什么区别
px是固定单位。
em:是相对单位,相对于父元素字体
rem:相对单位,相对于根元素(html)字体大小
7.解释下面代码的作用?为什么要加引号? 字体里\5b8b\4f53代表什么?

设置了body的font样式,字体大学为12px,行高是字体的1.5倍,同时设置了一堆的字体,如果第一个字体么有就找第二个,如果第二个没有,则以此类推。
字体加引号是为了 采用中文或英文字体的时候有空格,为了识别清楚,不产生乱码,所以加了引号。
\5b8b\4f53是Unicode码,而且全球通用,也是为了防止在个别浏览器上无法识别,所以用Unicode来表达的。

代码1:https://jsbin.com/difowid/edit?html,css,output
代码2:https://jsbin.com/tiduji/edit?html,css,output
代码3:https://jsbin.com/xejixow/edit?html,output
代码4:在上面已经写了
网友评论