html - Div 内容未显示在正确的位置,因为在 div 具有位置 : relative 之前

标签 html css position

<分区>

我有这样的代码:

<div style="position:relative">
    <div style="float:left; width: 183px; background-color:#c1cba9; color: #000000;"><img border="0" alt="Product categories" title="Product categories" src="graphic/categrieshead.png" width="179" height="43"><br />
        <div style="margin-left: 10;">Links goes here</div><br />
        <img border="0" src="graphic/catbot.png" width="179" height="17"></div>
    <div style="float:left; width: 480px; height:100px; text-align: center;"><img border="0" src="graphic/description.png" width="232" height="81"><br /><div style="text-align: left; margin-left: 10;">asasasas</div></div>
    <div style="float:left; width: 322px; height:100px; text-align: center;">
        <div style="width: 300px; color: #ffffff; background-color:#6b8861; font-size : 34px;">Item title</div>
        <div style="width: 300px; color: #ffffff; background-color:#6b8861;"><div style="width: 296px; margin: 2 2 2 2; background-color:#ffffff;">Item picture</div><div style="width: 300px; height: 2px; background-color:#6b8861; color: #6b8861;"></div></div>
        <div style="width: 300px; color: #801010; font-size : 60px;">Price: 20£</div>
    </div>
</div>

我需要添加 div 内容(文本)将出现在这三个 div 下,但是通过简单地添加它,文本出现在不正确的位置(右侧超出边界),我怎么能在我提到的部分之后添加 div它会出现在预览的那个部分下面吗?

最佳答案

在 float 元素之后使用带有 clear:both; 的元素:

<div style="clear: both;"></div>

在此之后,您可以插入新的内容 div,它将位于其他内容的下方。

关于html - Div 内容未显示在正确的位置,因为在 div 具有位置 : relative 之前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14236218/

上一篇:html - 在图像上定位图像和链接

下一篇:javascript - 使用 Google chrome api 缓存 .js 和 .css 文件

相关文章:

javascript - 如何使用只读文本框 Angular 显示垂直图像?

javascript - HTML 不延伸到服务器上的窗口但在本地工作

带有 + 和 - 的 jQuery Accordion 式常见问题解答

html - 媒体查询正在运行,但与它们应有的方式相反

css - 将一个 div 框居中

javascript - 如何确定列表中的位置以插入 div

css - 居中位置 :fixed div

具有不同高度的 CSS Floating Div 与它们之间的空间对齐

html - DIV CSS 布局 - 固定位置展开父级

javascript - 如何停止这个移动的div