[英]problem surrounding my website with a border using div tags
I want a div border to surround my entire website but instead the border is not moving dynamically as i add elements to the page. 我希望div边框围绕我的整个网站,但是当我向页面添加元素时,边框不会动态移动。 Instead it just surrounds the first 2 elements, the text and the image but not my tabled menu, but if i delete the div tag surrounding my table then the border will surround the table.
相反,它只是围绕前两个元素,即文本和图像,而不是我的表格菜单,但是如果我删除表格周围的div标签,则边框将围绕表格。 I need the div tags to organise my site though so can anyone help me please... The problem seems to come from the float tag in the content_col1 div tag but i need float to place div tags next to each other.
我需要div标签来组织我的网站,但是任何人都可以帮助我...问题似乎来自content_col1 div标签中的float标签,但是我需要float才能将div标签彼此相邻放置。
Heres the HTML 继承人的HTML
<div id="content">
<div id="content_topTitle">
Welcome to the greatest local online grocery store the world has ever seen!
</div>
<div id="content_images">
<img src="image/image1.jpg" />
</div>
<!-- /////////////////////////// -->
<!-- /////////////////////////// -->
<!-- /////////////////////////// -->
<!-- /////////////////////////// -->
<div id="content_col1">
<table width = 100% cellpadding = "0" cellspacing = "0">
<tr>
<td class = "departments"><a class = "departments" href="">Bakery</a></td>
</tr>
<tr>
<td class = "departments"><a class = "departments" href="">Vegetables</a></td>
</tr>
<tr>
<td class = "departments"><a class = "departments" href="">Sweets</a></td>
</tr>
<tr>
<td class = "departments"><a class = "departments" href="">Meats</a></td>
</tr>
<tr>
<td class = "departments"><a class = "departments" href="">Dairy</a></td>
</tr>
<tr>
<td class = "departments"><a class = "departments" href="">Bakery</a></td>
</tr>
<tr>
<td class = "departments"><a class = "departments" href="">Vegetables</a></td>
</tr>
<tr>
<td class = "departments"><a class = "departments" href="">Sweets</a></td>
</tr>
</table>
</div>
</div>
and here's the CSS 这是CSS
#content
{
background: #eee;
border: 5px solid #68accc;
padding: 0px;
}
#content_topTitle
{
text-align: center;
height: 35px;
line-height: 35px;
font-weight: bold;
}
#content_images
{
width:880px;height:200px;
}
#content_col1
{
float: left;
width: 130px;
padding: 10px;
}
The easiest way to solve the problem is to set the overflow on the surrounding element like for example: 解决问题的最简单方法是在周围的元素上设置溢出,例如:
#content
{
background: #eee;
border: 5px solid #68accc;
padding: 0px;
overflow: hidden;
}
You need a clearfix on the #content div. 您需要在#content div上使用clearfix。
http://css-tricks.com/snippets/css/clear-fix/ http://css-tricks.com/snippets/css/clear-fix/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.