gpt4 book ai didi

html - 为什么这个 html 边框只有 3 个边?

转载 作者:太空宇宙 更新时间:2023-11-03 20:51:10 25 4
gpt4 key购买 nike

为什么:

<html>
<head>
<style>
#categorizer { border-style: solid; border-width: 10px;
border-color: blue; padding: 50px }
#children { color: green; background-color: yellow }
#parents { color: blue; background-color: #ccc }
</style>
</head>
<body>
<span id="categorizer">
<span id="children">
<span class="child">c11111</span>
<span class="child">c22222</span>
<span class="child">c33333</span>
<span class="child">c44444</span>
<span class="child">c55555</span>
</span>
<span id="parents">
<span class="parent">pAAA</span>
<span class="parent">pBBB</span>
</span>
</span>
</body>
</html>

只给我三个边界边,即

enter image description here

最佳答案

正如 Cody Guldner 在他的评论中暗示的那样,您的 span 是内联元素,而不是 block 元素。因此,填充不会改变文本的垂直间距;它只是在文本周围添加填充,然后将边框添加到填充的边缘。正是这种填充将顶部的蓝色边框推到看不见的地方。

关于html - 为什么这个 html 边框只有 3 个边?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15863747/

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