task8

2017-07-24  本文已影响0人  peaceChierdo

问答

为何img、input等内联元素可设置宽高

1. 块级元素和行内元素分别有哪些?动手测试并列出4条以上的特性区别

块级元素: p, h1~h6, div, form, ul, ol, li, address, fieldset, hr, menu, table
行内元素: strong, em, span, br(替换元素), img(..) , input, label, select, textarea, cite

区别:

当一个元素的可以继承的属性没有设置时,默认继承其父元素对此属性的设置。

  • 继承性的属性:
-  字体相关属性:font,font-family,font-weight,font-size,font-style,font-stretch,font-size-adjust
-   文本相关属性:text-indent(文本缩进),text-align,line-height,word-spacing,letter-spacing,text-transform,direction,color
-  元素可见性:visibility
- 表格布局属性:caption-side,border-collapse,border-spacing,empty-cells,table-layout
- 列表布局属性:list-style-type,list-style-image,list-style-position,list-style
- 生成内容属性:quotes
- 光标属性:cursor
- 页面样式属性:page,page-break-inside,window,orphans
- 声音样式属性:speak,speak-punctuation....

3. 如何让块级元素水平居中?如何让行内元素水平居中?

块级元素水平居中:设置其宽度,并把左右margin设为auto
行内元素水平居中:text-align: center;

4. 用 CSS 实现一个三角形

canvas.png

5. 单行文本溢出加 ...如何实现?

white-space:nowrap;   
overflow:hidden; 
text-overflow:ellipsis;

6. px, em, rem 有什么区别

px: 绝对/固定单位,浏览器默认文字大小为16px
em: 相对单位,表示当前字体大小是父容器字体大小的多少倍
rem:相对单位,表示当前字体大小是根元素(html)字体大小的多少倍

7. 解释下面代码的作用?为什么要加引号? 字体里\5b8b\4f53代表什么?

body{
  font: 12px/1.5 tahoma,arial,'Hiragino Sans GB','\5b8b\4f53',sans-serif;
}

对body设置字体大小为12px,行高为字体大小的1.5倍,

tahoma,arial,'Hiragino Sans GB','\5b8b\4f53',sans-serif表示字体选择的优先顺序,(如果存在)排在前面的字体会优先使用
'\5b8b\4f53':是“宋体”的Unicode编码表示

8.代码实现

上一篇 下一篇

猜你喜欢

热点阅读