CSS样式

块级元素和行内元素分别有哪些?动手测试并列出4条以上的特性区别
  • 块级元素:div , p , form, ul, li , ol, dl, form, address, fieldset, hr, menu, table
  • 行内元素:span, strong, em, br, img , input, label, select, textarea, cite,
  • 区别:
    块级元素:块状元素排斥其他元素与其位于同一行,可以设定元素的宽(width)和高(height),块级元素一般是其他元素的容器,可容纳块级元素和行内元素。
    行内元素:行内元素不可以设置宽(width)和高(height),但可以与其他行内元素位于同一行,行内元素内一般不可以包含块级元素。行内元素的高度一般由元素内部的字体大小决定,宽度由内容的长度控制。margin上下无效左右有效,padding上下无效左右有效。
什么是 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。
如何让块级元素水平居中?如何让行内元素水平居中?
  • 块级元素水平居中: margin:0 auto
  • 行内元素水平居中:在其父级元素上设置 text-align: center
用 CSS 实现一个三角形
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
  <style>
    .tri {
      width: 0;
      height:0;
      border-top: 100px solid transparent;
      border-right: 100px solid transparent;
      border-left: 100px solid transparent;
      border-bottom: 100px solid blue;
    }
  </style>
</head>
<body>
  <div class="tri"></div>
</body>
</html>```
预览地址:[css实现三角形](http://js.jirengu.com/pekaquhexa/1/edit)
#####单行文本溢出加 ...如何实现?

E {
white-space: nowrap;
overflow: hidden;
text-overflow:ellipsis;
}```

px, em, rem 有什么区别
  • px: (Pixel)相对长度单位,像素px是相对于显示器屏幕分辨率而言的
  • rm: 相对长度单位,相对于父元素
  • rem: 相对长度单位,相对的是HTML根元素
解释下面代码的作用?为什么要加引号? 字体里\5b8b\4f53代表什么?
body {
  font: 12px/1.5 tahoma,arial,'Hiragino Sans GB','\5b8b\4f53',sans-serif;
}```
有空格,不加引号会被识别成两个字体;
数字是Unicode码,宋体、微软雅黑。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 13,815评论 1 92
  • 一.基础知识 1.基本构成:选择符和声明,声明包括属性和值。 2.注释/*...*/ 3.在html中插入形式(离...
    三姨妈在简书阅读 536评论 0 0
  • 去掉下划线: text-decoration:none; 占四分之一的距离: width:25% 居中对齐:tex...
    writeanewworld阅读 387评论 0 0
  • 字体属性:(font) 大小 {font-size: x-large;}(特大) xx-small;(极小) 一般...
    米塔塔阅读 597评论 1 12
  • 字体属性:(font) 大小 {font-size: x-large;}(特大) xx-small;(极小) 一般...
    可爱傻妞是我的爱阅读 314评论 0 0