CSS常见样式

2017-03-11  本文已影响0人  饥人谷_saybye

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

什么是 CSS 继承? 哪些属性能继承,哪些不能?

即子元素继承其父元素的属性

  1. 字体属性类 font-family , font-weight , font-size , font-style
  2. 文本系列属性 text-indent , text-align , line-height , word-spacing, letter-spacing , color
  3. 元素可见性 visibility
  4. 表格布局属性 caption-side , border-collapse , border-spacing , empty-cells , table-layout
  5. 列表布局属性 list-style-type , list-style-image , list-style-position , list-style
  1. display
  1. 文本属性 vertical-align ,text-decoration ,text-shadow , white-space
  2. 盒子模型的属性 width、height、margin、border、border-style、border-width、border-color、padding
  3. 背景属性 background、background-color、background-image、background-repeat、background-position、background-attachment
  4. 定位属性float、clear、position、top、right、bottom、left、min-width、min-height、max-width、max-height、overflow、clip、z-index

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

块级元素:margin:0 auto;(0的值为上下可随意)
行内元素:对其父元素设置text-align:center

用 CSS 实现一个三角形

<style>
       div{
           width: 0px;
           height: 0px;
           border: 50px solid;
           border-color:transparent transparent blue transparent;
}
</style>
       <div></div>```

## 单行文本溢出加 ...如何实现?
 ```white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;```

## px, em, rem 有什么区别
px:像素,固定单位
em:相对单位,相对于父元素字体大小
rem:相对单位,相对于根元素(html)字体大小

## 解释下面代码的作用?为什么要加引号? 字体里\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这些为设置字体,从左到右依次寻找浏览器和系统中是否存在
'Hiragino Sans GB'加引号是说明这是一种字体,不然会被解析成3种字体
'\5b8b\4f53'为宋体的Unicode编码表示方式,是为了防止直接写中文的情况下编码(GB2312、UTF-8 等)不匹配时会产生乱码。

上一篇 下一篇

猜你喜欢

热点阅读