gpt4 book ai didi

html - 为什么div显示:table-row ignore margin?

转载 作者:太空狗 更新时间:2023-10-29 13:22:02 24 4
gpt4 key购买 nike

除了 margin-top 被表格行 div 完全忽略之外,以下 html 可以正常工作。我不知道为什么。

<div class='table'>

<div class='margin-top5 row user' id='user_113'>
<div class='cell left avatar margin-right5'><img alt="Blank_avatar_thumb" src="/images/blank_avatar_thumb.png?1295354025" /></div>
<div class='cell left'>
<div class='bold'><a href="/voisins/113">Dandre</a></div>
<div class='small of_hidden'>toothpicking, veryveryveryveeerrrryyyyyylooooooooong, kidnapping...</div>
</div>
<div class='cell right'>42</div>

<div class='clear'></div>
</div>
/* more rows */
</div>

CSS:

div.table {
display: table;
width: 100%;
}
div.row {
display: table-row;
}
div.cell {
display: table-cell;
}
div.left {
float: left;
}
div.right {
float: right;
}
div.clear {
clear: both;
}
.avatar {
vertical-align: middle;
}
.margin-top5 {
margin-top: 5px;
}
.margin-right5 {
margin-right: 5px;
}
.bold {
font-weight: bold;
}
.of_hidden {
overflow: hidden;
}
.small {
font-size: 0.8em;
}
body, p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}

编辑:

如果我从行 div 中删除 .row 类,它会开始获取 margin-top。

最佳答案

这是罪魁祸首:display: table-row;你告诉 div 表现得像 trtr 没有 margin... 或 padding

您可以将 padding 应用于 td,但不能应用于 margin

关于html - 为什么div显示:table-row ignore margin?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4738601/

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