美文网首页
CSS常见样式

CSS常见样式

作者: 风之聖痕 | 来源:发表于2017-02-25 16:09 被阅读7次

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

    块级元素:

    div h1 h2 h3 h4 h5 h6 p hr form ul dl ol pre table
    li dd dt tr td th

    行内元素:
    button input label select textarea  code script```
    ######区别:
    1.  行内元素会在一条水平方向上的直线排列,而块级元素各占据一行,垂直方向排列
    2.   块级元素可以包含行内元素和块级元素;行内元素不能包含块级元素
    3.  行内元素与块级元素属性不同,比如在盒模型属性上,行内元素设置width无效,height无效,上下margin无效,上下padding无效
    4.  对应display属性值不同,块级元素对应为block,行内元素对应为inline
    
    
    ###2.   什么是 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。
    
    ###3.   如何让块级元素水平居中?如何让行内元素水平居中?
    块级元素水平居中:```margin : 0 auto;```
    行内元素水平居中:`text-align : center;`
    
    ###4.   用 CSS 实现一个三角形
    
    ![triangle](https://img.haomeiwen.com/i1347915/2040af7eca415901.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    
    ###5.   单行文本溢出 ...如何实现?
    通过以下三行css代码实现 
     `white-space: nowrap; `     
    ` overflow: hidden; `           
    ` text-overflow: ellipsis; `   
    
    ###6.   px, em, rem 有什么区别
    - px:固定单位
      
    - em:相对单位,相对于父元素字体大小
    - rem;相对单位,相对于根元素(html)字体大小
    
    
    ###7.   解释下面代码的作用?为什么要加引号? 字体里\5b8b\4f53代表什么?
     ```body{
      font: 12px/1.5 tahoma,arial,'Hiragino Sans GB','\5b8b\4f53',sans-serif;
    }```
    
    - 代码给body设置字体的大小,行高,字体的种类。
    
    - 加引号是因为这个字体有两个单词,不加引号就会被解读成两个字体。
    
    - \5b8b\4f53是“宋体”的unicode码,其中\5b8b代表的是“宋”,\4f53代表的是“体”。\5b8b\4f53即表示宋体。

    相关文章

      网友评论

          本文标题:CSS常见样式

          本文链接:https://www.haomeiwen.com/subject/dtqnwttx.html