首页 > Web开发 > 详细

css3自适应法宝fill-available、fit-content、max-content、min-content

时间:2021-05-12 20:21:34      阅读:28      评论:0      收藏:0      [点我收藏+]

1,fill-available表示撑满可用空间(包括高度,宽度),下面一个栗子,表示下

<style type="text/css">
.box{
width: 60%;
height: 500px;
border: 1px solid #f00;
margin: 20px auto 0;
}
.son{
width: -webkit-fill-available;
background: #ff0;
height:200px;/*高也可以是fill-available*/
}
</style>
<div class="box">
<div class="son"></div>
</div>
2,fit-content

fit-content表示宽度缩小到内容的宽度,

3,max-content

max-conten表示用内部元素宽度值最大的那个元素的宽度作为最终容器的宽度。简单了说就是文字不换行

4,min-content

min-content表示用内部元素最小宽度值最大的那个元素的宽度作为最终容器的宽度。这个最小宽度值有最大什么意思,如果是图片的话最小宽度值就是图片所呈现的宽度,如果是汉字就是一个字的宽度,如果是英文就是单词的宽度

<style>
.box{
width:-webkit-min-content;
border:1px solid pink;
}
.brother{
width: 120px;
height: 20px;
background: #f00;
}
</style>
<div class="box">
<div class="brother"></div>
<div class="son">八百标兵奔北坡,炮兵并排北边跑</div>
</div>

css3自适应法宝fill-available、fit-content、max-content、min-content

原文:https://www.cnblogs.com/fgwh-y/p/14761130.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!