内容简介:每日两道前端面试题20190307希望睡一觉起来 阳光会出来.
CSS3新增伪类有那些?
- p:first-of-type:选择属于其父元素的首个<p>元素
- p:last-of-type:选择属于其父元素的最后<p>元素
- p:only-of-type:属于父元素的特定类型的唯一子元素
- p:only-child:属于父元素的唯一子元素的每个<p>元素
- p:nth-child(2):选择父元素的第二个子元素
- ::after 在元素之前添加内容
- ::before 在元素之后添加内容
- :enabled 已启用
- :disabled 控制表单为禁用状态,不可点击
- :checked 单选框或复选框被选中
如何居中div
第一种方式:给div设置一个宽度,然后添加margin:0 auto属性.
div{
width:200px;
margin:0 auto;
}
第二种方式:让绝对定位的div居中
div{
position:absolute;
width:300px;
height:300px;
margin:auto;
top:0;
left:0;
bottom:0;
right:0;
background-color:pink;
}
第三种方式:水平垂直居中一
div{
position:relative;
width:500px;
height:300px;
top:50%;
left:50%;
margin:-150px 0 0 -250px;
background-color:pink;
}
第四种方式:未知容器的宽高,利用'transform'属性
div{
position:absolute;
width:500px;
height:300px;
top:50%;
left:50%;
transform:translate(-50%,-50%)
background-color:pink;
}
第五种方式:利用flex布局,需考虑兼容性
container{
display:flex;
align-item:center;/*垂直居中*/
justify-content:center;/*水平居中*/
}
container div{
width:100px;
height:100px;
background-color:pink
}
每日两道前端面试题20190307
希望睡一觉起来 阳光会出来.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Web Application Hacker's Handbook
Dafydd Stuttard、Marcus Pinto / Wiley / 2011-9-27 / USD 50.00
The highly successful security book returns with a new edition, completely updated Web applications are the front door to most organizations, exposing them to attacks that may disclose personal infor......一起来看看 《The Web Application Hacker's Handbook》 这本书的介绍吧!
XML、JSON 在线转换
在线XML、JSON转换工具
RGB HSV 转换
RGB HSV 互转工具