css题

一.CSS 选择符有哪些?哪些属性能够继承?优先级算法如何计算?
1.id选择器( # myid) 2.类选择器(.myclassname)3.标签选择器(div, h1, p)  4.相邻选择器(h1 + p)
5.子选择器(ul < li)    6.后代选择器(li a)
7.通配符选择器( * ) 9.伪类选择器(a: hover, li: nth - child)
可继承的样式: font-size font-family color, ul li dl dd dt;
不可继承的样式:border padding margin width height ;
 优先级就近原则,同权重状况下样式定义最近者为准;
 载入样式以最后载入的定位为准;
 优先级为:
  !important > id > class > tag important 比 内联优先级高
CSS3新增伪类有那些?
p:last-of-type 选择其父元素的最后的一个P元素
p:first-of-type 选择其父元素的首个P元素
p:nth-child(n)   选择其父元素的第N个 恰好是p的元素
p:nth-last-child(n) ..............................................从最后一个子元素开始计数
p:nth-of-type(n)  选择其父元素的n个元素
p:nth-last-of-type(n) ........................从最后一个子元素开始计数
二.css水平、垂直居中的写法,请至少写出4种?
水平居中
行内元素: text-align: center
块级元素: margin: 0 auto
position:absolute +left:50%+ transform:translateX(-50%)
display:flex + justify-content: center
垂直居中
设置line-height 等于height
position:absolute +top:50%+ transform:translateY(-50%)
display:flex + align-items: center
display:table+display:table-cell + vertical-align: middle;
三.画一条0.5px的直线?
考查的是css3的transform
height: 1px;
transform: scale(0.5);缩放
四.s说一下盒模型?
盒模型是css中重要的基础知识,也是必考的基础知识
盒模型的组成,由里向外content,padding,border,margin.
在IE盒子模型中,width表示content+padding+border这三个部分的宽度
在标准(w3c)的盒子模型中,width指content部分的宽度
box-sizing的使用
box-sizing: content-box 是W3C盒子模型
box-sizing: border-box 是IE盒子模型
box-sizing的默认属性是content-box
五.清除浮动的最经常使用的四种方法,以及优缺点
1.额外标签法(在最后一个浮动标签后,新加一个标签,给其设置clear:both;)(不推荐)
2.父级添加overflow属性(父元素添加overflow:hidden)(不推荐)
3.使用after伪元素清除浮动(推荐使用)
.clearfix:after{/*伪元素是行内元素 正常浏览器清除浮动方法*/
content: "";
display: block;
height: 0;
clear:both;
visibility: hidden;
}
.clearfix{
*zoom: 1;/*ie6清除浮动的方式 *号只有IE6-IE7执行,其余浏览器不执行*/
}
4.使用before和after双伪元素清除浮动
.clearfix:after,.clearfix:before{
content: "";
display: table;
}
.clearfix:after{
clear: both;
}
.clearfix{
*zoom: 1;
}
六。说一下<label>标签的用法
label标签主要是方便鼠标点击使用,扩大可点击的范围,加强用户操做体验
css3实现一个三角形 等腰
<div class="kailong"></div>css

.kailong{
width:0;
height:0;
border-right:50px solid transparent;
border-left:50px solid transparent;
border-bottom:50px solid red;
}
css3新特性
1.实现圆角 boder-radius
2.对文字加特效boder-shadow(阴影) rgba(透明度)
3.旋转,缩放,定位,倾斜 :transform:适用于2D或3D转换的元素 scale
.过渡transition: CSS属性,花费时间,效果曲线(默认ease),延迟时间(默认0)
/*宽度从原始值到制定值的一个过渡,运动曲线ease,运动时间0.5秒,0.2秒后执行过渡*/
transition:width,.5s,ease,.2s
4.动画 /*执行一次logo2-line动画,运动时间2秒,运动曲线为 linear*/
animation: logo2-line 2s linear;
5.flex 弹性布局 box {
display: flex;
justify-content: center;
} 水平居中
.box {
display: flex;
align-items: center;
} 垂直居中css3

相关文章
相关标签/搜索