gpt4 book ai didi

html - 为什么我的网站文字与图片重叠?

转载 作者:行者123 更新时间:2023-11-28 17:38:50 25 4
gpt4 key购买 nike

所以在我的网站上,在这个页面上http://dunnrite.co.uk/our_work右侧文本应该在右侧,但有时在 chrome 和其他浏览器中它会覆盖图像。当您刷新几次或调整浏览器大小时(我的网站是响应式的),它会恢复正常。

这是 HTML 代码:

<div id="content_box">

<div id="left_side_work">
<h3>Our Work</h3>
<a class="fancybox" rel="group" href="Images/Clubz4u.jpg">
<div id="clubz4u_pic"></div>
</a>
<a target="blank" href="http://beauxcadeaux.co.uk">
<div id="beaux_cadeaux_pic"></div>
</a>
</div>

<div id="right_side_work">
<h3>Clubz4u</h3></br>
<p>Clubz4u was a social enterprise that Dunn Rite set up for DHSB school. It enabled club owners/event organisers to list their activity's details on our site for free.
This also meant that anyone looking to join a club could easily see the clubs on offer in their region.
To help cover any costs associated with setting up the website Clubz4u had live adverts placed by Google which when clicked generated income.
We also produced interactive Facebook features.
</p>
<div id="beaux_cadeax_text">
<h3 style="margin-top:150px;">Beaux Cadeaux</h3></br>
<p>Beaux Cadeaux is an online gift shop created by husband and wife Val and Richard Cass. They recently created their own website and needed Dunn Rite's assistance gaining some SEO. Richard commented on our Dunn Rite representative saying "I have found you to have a maturity and professionalism beyond your years. You have been helpful and efficient. It would be good to think that we could both benefit from working with each other in the future."
</p>
</div>
</div>

<div id="nextpage">
<a href="our_work2">Next &rarr;</a>
</div>
</div>

和对应的CSS

#left_side_work {
width: 40%;
padding-top: 30px;
left: 0;
margin-left: -250px;
float: left;
}

#right_side_work {
margin-top: 35px;
display: inline-block;
width: 400px;
height: auto;
float: right;
margin-left: 70px;
position: absolute;
}

有什么想法吗?

谢谢

最佳答案

快速回答:从 #right_side_work 中删除 float: right

更长的答案:甚至不要考虑将绝对定位用于布局目的(以及大多数其他用途),因为您允许 block 将一个叠加在另一个之上......失败。
不必同时使用 float 定位和绝对定位:可以使用 right: 0 将其定位到右侧(但不要使用绝对定位)。
float block 应该首先出现在您的 HTML 代码中。如果它是一个 div 并且它是 float 的,为什么还要设置 inline-block

您是否尝试在每张图片旁边显示文字?那么您的 HTML 代码应该是:image1 - text1 - image2 - text2 - etc,而不是 (all the image) - (all the text)。创建内容的行/行,然后在每列中创建内容,而不是 2 个巨大的文本列,即使进行最轻微的修改也永远不会水平对齐。

最后,leftrighttopbottom 属性仅在元素位于某种方式。此处对左侧部分没有影响。

关于html - 为什么我的网站文字与图片重叠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24585756/

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