css3 display的几个常用属性
发布时间:2020-11-28 19:48:15
css3 display的常用属性
none: 元素隐藏,但依然存在。
例子
html部分
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
css部分
.box1{
width: 100px;
height: 50px;
background-color: #ffff00;
}
.box2{
width: 120px;
height: 70px;
background-color: cyan;
display: none;
}
.box3{
width: 150px;
height: 90px;
background-color: red;
}
inline: 使元素变成行内元素,拥有行内元素的特性,它会随着文档的文字流动, 不独占一行,不能设置宽高,大小由内容撑开
html部分
<div class="box1"> div </div>
<div class="box2"></div>
<div class="box3"></div>
css部分
.box1{
width: 100px;
height: 50px;
background-color: #ffff00;
display: inline;
}
.box2{
width: 120px;
height: 70px;
background-color: cyan;
display: none;
}
.box3{
width: 150px;
height: 90px;
background-color: red;
}
block: 使元素变成块级元素,独占一行,可以设置宽高,默认填满父级的宽度。
html部分
<span> spanspanspan </span>
css部分
span{
width: 100px;
height: 50px;
display: block;
background-color: green;
}
inline-block: 使元素变成行内块元素,可以设置宽高,就是不独占一行的块级元素。
例子
html部分
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
css部分
.box1{
width: 100px;
height: 50px;
background-color: #ffff00;
display: inline-block;
}
.box2{
width: 120px;
height: 70px;
background-color: cyan;
display: inline-block;
}
.box3{
width: 150px;
height: 90px;
background-color: red;
display: inline-block;
}
远近互联前端小王整理发布,希望能对学习技术的你有所帮助
远近互联专业提供网站建设、APP开发、网站优化、外贸网站SEO、微信运营的品牌整合营销服务让客户通过网络品牌建立与网络传播提高业绩。
-
定制网站建设的标准化体系:从需求分析到上线了解详情 >
-
石家庄网站制作公司:助力企业打造一个优质的营销网站了解详情 >
-
积分商城系统开发:助力企业提升用户体验与运营效率了解详情 >
-
旅游行业小程序都具备哪些功能:提升用户体验,助力业务增长了解详情 >
-
石家庄中小企业如何通过小程序开发提升竞争力了解详情 >
-
制造业小程序开发,如何开发一个小程序?了解详情 >
-
会员系统开发:提升企业管理效率的关键了解详情 >
-
小程序开发公司哪家好?这几家不得不看!了解详情 >
-
石家庄做网页设计的公司,能够做网页设计和网站开发了解详情 >
-
为什么选择石家庄小程序开发公司,助力企业数字化转型了解详情 >