gpt4 book ai didi

css - 带有伪CSS的背景颜色层

转载 作者:太空宇宙 更新时间:2023-11-04 10:31:18 24 4
gpt4 key购买 nike

 .product-item-info::after {
background-color: #e3e3e3;
content:" ";
height:300px;
width:300px;
}

.product-item-info {
height: 300px;
}
<div class="product-item-info"></div>

是否可以创建一个彩色背景层作为伪元素,我现在尝试但没有用

.product-item-info:after {
background-color: #e3e3e3;
content:"";
height:300px;
width:400px;
}

最佳答案

::before::after默认情况下是 display: inline。您需要为要应用的 widthheight 属性设置 display: block:

.product-item-info::after {
background-color: #e3e3e3;
content:" ";
height: 300px;
width: 300px;
display: block; /* this is what you need */
}

.product-item-info {
height: 300px;
background-color: red; /* for demonstration purposes */
}
<div class="product-item-info"></div>

关于css - 带有伪CSS的背景颜色层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36478175/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com