美文网首页
CSS常见样式

CSS常见样式

作者: 柚丶稚橙熟时 | 来源:发表于2017-04-27 14:29 被阅读0次

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

    块级元素:
    div h1 h2 h3 h4 h5 h6 p hr
    form ul dl ol pre table
    li dd dt tr td th
    
    行内元素:
    em strong span a br img 
    button iput label select textarea
    code script 
    

    特性区别:

    1. 块级元素占据一整行;行内元素占据自身大小而不是一整行;
    2. 块级元素可以设置宽高属性;行内元素要设置宽高属性须设置 display:inline-block;(可置换行内元素可以设置宽高,如img|input|select|textarea|button|label等)。
    3. 块级元素可以正常设置 padding margin样式;行内元素padding margin属性只有左右生效,上下不生效。
    4. 块级元素居中用 margin:0 auto;(要设置宽度且不能定位浮动);行内元素居中则给父元素设置text-align:center; 样式

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

    css继承:设置父级元素,其子级元素的样式会和父级元素一样。

    不可继承的: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。

    所有元素可继承: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。

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

    块级元素居中用 margin:0 auto;(要设置宽度且不能定位浮动);行内元素居中则给父元素设置text-align:center; 样式

    用 CSS 实现一个三角形

    <style>
        .san{
          width:0;
          height:0;
          border-top:30px solid transparent;
          border-right:30px solid transparent;
          border-left:30px solid red;
          border-bottom:30px solid red;
        }
    </style>
    <body>
      <div class="san"></div>
    </body>
    

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

    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倍12px,字体使用tahoma找不到则用arial 依次类推;
    加引号是因为字体单词间有空格防止被认为多个字体;
    代表字体的Unicode;


    相关文章

      网友评论

          本文标题:CSS常见样式

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