gpt4 book ai didi

css - 如何折叠一个空的 div?

转载 作者:技术小花猫 更新时间:2023-10-29 11:45:01 28 4
gpt4 key购买 nike

我有一个要用于动态内容的 div。当填充div的内容不存在时,我不想看到它。现在,我可以看到大约 5px 的框。即使我移除填充,我仍然可以看到大约 1px 的框。没有内容时如何去掉盒子?

#test {
border:1px dashed red;
font-size:16px;
margin:20px 0 0 0;
width:332px;
background-color:#eee;
padding:5px 0 5px 60px;
}

最佳答案

你可以在 CSS 中做:

 div#test:empty {
display: none;
}

关于css - 如何折叠一个空的 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4991907/

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