[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
什么是flex-grow 属性❓
flex-grow 属性用于设置或检索弹性盒子的扩展比率。
❗注意:如果元素不是弹性盒对象的元素,则 flex-grow 属性不起作用。
CSS 语法
flex-grow: number|initial|inherit;
属性值
值描述
number一个数字,规定项目相对于其他灵活的项目进行扩展的量。默认值是 0。
initial设置该属性为它的默认值。
inherit从父元素继承该属性。
测试代码
<!DOCTYPE html> <html> <head> <style> #main { width: 350px; height: 100px;
border: 1px solid #000; display: flex; } #main div:nth-of-type(1) {flex-grow:
1;} #main div:nth-of-type(2) {flex-grow: 3;} #main div:nth-of-type(3)
{flex-grow: 1;} #main div:nth-of-type(4) {flex-grow: 1;} #main
div:nth-of-type(5) {flex-grow: 1;} </style> </head> <body> <div id="main"> <div
style="background-color:coral;">1</div> <div
style="background-color:lightblue;">3</div> <div
style="background-color:khaki;">1</div> <div
style="background-color:pink;">1</div> <div
style="background-color:lightgrey;">1</div> </div> </body> </html>
效果图
关于flex-grow属性的例题
1、flex-grow的作用是(D)
A、 弹性盒子元素对齐方式
B、 弹性盒子元素的排列方式
C、 弹性盒子元素显示次序
D、 弹性盒子元素如何分配剩余空间