gpt4 book ai didi

html - 固定数量的 CSS 调整大小

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

您好,我在调整 DIV 大小方面遇到了问题。

我不知道为什么,但我在特定部分的特定类的所有 div 都比它们应该的大 70 像素。如果此类的 div 是 300px 或 800px,就会发生这种情况。

出于这个原因,我不能使用任何百分比,因为没有固定值。高度仅取决于 div 中的文本量。

我怎样才能消除这个偏移量?我可以使用任何东西,甚至是 Javascript 或类似的东西。

我已经做了类似的事情:

底部边距:-70px;

它有效,但使用此解决方案,前一篇文章的 div 与新标题重叠。使部分标题不可点击。

谢谢

编辑:

我当前这部分的 CSS 是空的。

当然谢谢..

<div class="lcp_catlist">
<div class="list_cat_begin_post">

<a href="..."><img ..."></a>

<span class="list_cat_post_title_span">
<span class="list_cat_post_data"> 4 gennaio 2015</span>
<a href="....">TITLE</a>
</span>

<div class="list_cat_excerpt">
EXCERPT
</div>
</div>
..... [many <div class="list_cat_begin_post">]

</div>

.lcp_catlist {
position: relative;
top: 10px;
}

.list_cat_begin_post {
}

.list_cat_post_title_span {
position: relative;
top: -95px;`enter code here`
background: rgba(12, 97, 157, 0.7);
color: white;
display: table-cell;
width: 620px;
height: 75px;

.list_cat_excerpt {
position: relative;
top: -80px;
bottom: 5px;
border-bottom: solid;
border-color: rgb(12, 97, 157);

问题快照![红色方 block 突出显示不应出现的空间] http://i62.tinypic.com/zxn24n.png

最佳答案

在看到添加的代码后,我会说这是导致问题的位置关系。当您将某些内容设置为相对位置时,它在文档中的位置就像它在那里一样,然后将它移动到相对于它通常同时位于的位置但保留它的空间。所以这个片段明白我的意思,它已经将绿色框向下推,但仍保留在文档中。

#box2{width:150px;height:30px;background-color:yellow;}
#box3{width:150px;height:30px;background-color:blue;}
#box4{position:relative;width:150px;height:30px;top:10px;background-color:green;}
<div id="box2">&nbsp;</div>
<div id="box4">&nbsp;</div>
<div id="box3">&nbsp;</div>

关于html - 固定数量的 CSS 调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27890860/

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