美文网首页
CSS常见样式1

CSS常见样式1

作者: cross_王 | 来源:发表于2017-06-17 16:00 被阅读0次

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

    • 块级元素有 html,body,h1~h6,p,div,ul,ol,li,dl,dd,dt,form,table,th,td,tr
    • 行内元素有 span,把,i,u,s,em,u,s,em,strong,input,br,a,img,label,select,textarea
    • 区别:1.块级元素独占一行,多个块级元素垂直排列,行内元素不能独占一行,多个行内元素可以水平排列,撑满浏览器后换行;2.块级元素可以包含块级元素和行内元素,行内元素只能包含行内元素和文本;3.块级元素可以设置宽高,行内元素的宽高由内容撑开;4.块级元素可以设置padding和margin,行内元素的padding和margin只有左右有效,上下只能撑开边框和背景,不能改变元素所占的位置.

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

    • css的继承是css的特定属性可以向下传递到子孙元素
    • 可以继承的属性: 1. 字体系列属性:font,font-size,font-family,font-weight,font-style,font-variant; 2. 文本系列属性:text-align,line-height,word-spacing,letter-spacing,text-transform,direction,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 6.生成内容属性:quotes 7.光标属性:cursor 8.页面样式属性:page、page-break-inside、windows、orphans 9.声音样式属性:speak、speak-punctuation、speak-numeral、speak-header、speech-rate、volume、voice-family、pitch、pitch-range、stress、richness、、azimuth、elevation
    • 不可继承的属性:
      1、display:规定元素应该生成的框的类型
      2、文本属性:
      vertical-align:垂直文本对齐
      text-decoration:规定添加到文本的装饰
      text-shadow:文本阴影效果
      white-space:空白符的处理
      unicode-bidi:设置文本的方向
      3、盒子模型的属性:width、height、margin 、margin-top、margin-right、margin-bottom、margin-left、border、border-style、border-top-style、border-right-style、border-bottom-style、border-left-style、border-width、border-top-width、border-right-right、border-bottom-width、border-left-width、border-color、border-top-color、border-right-color、border-bottom-color、border-left-color、border-top、border-right、border-bottom、border-left、padding、padding-top、padding-right、padding-bottom、padding-left
      4、背景属性:background、background-color、background-image、background-repeat、background-position、background-attachment
      5、定位属性:float、clear、position、top、right、bottom、left、min-width、min-height、max-width、max-height、overflow、clip、z-index
      6、生成内容属性:content、counter-reset、counter-increment
      7、轮廓样式属性:outline-style、outline-width、outline-color、outline
      8、页面样式属性:size、page-break-before、page-break-after
      9、声音样式属性:pause-before、pause-after、pause、cue-before、cue-after、cue、play-during

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

    • 对于设置了宽度的块级元素,使用为其设置左右的margin为auto使其居中.
    • 对于行内元素,为其祖先块级元素设置text-align: center.

    用 CSS 实现一个三角形

    • 为一个div设置如下样式,就可以得到一个蓝色三角形
      div {
      width: 0; height: 0; border: 30px solid transparent; border-bottom-color: blue;
      }

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

    • 设置文本不换行: whit-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,行高18px,字体依次选择tahoma,arial,'Hiragino Sans GB','\5b8b\4f53',sans-serif.
    • 加引号是因为有空格,不然会被认为多个字体
    • \5b8b\4f53是宋体的unicode编码

    相关文章

      网友评论

          本文标题:CSS常见样式1

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