通过在左侧放置 3 个 div 和在右侧放置 1 个 div,我遇到了一些问题……如果每侧只有 1 个 div,它就完美了……
我有一个新闻部分......它为每个新闻创建一个新的 div。
每页我会得到5个......(超过1个......右侧的div......将被推下......)
<?php foreach ($news as $news_item): ?>
<div id="NewsPageContent">
THIS STUFF
</div><!--End NewsPageContent-->
<?php endforeach ?>
所有代码:
<div id="boxes">
<?php foreach ($news as $news_item): ?>
<div id="NewsPageContent">
THIS STUFF
</div><!--End NewsPageContent-->
<?php endforeach ?>
<div id="PlayersOnline">
<h2>Players Online</h2><hr />
<div id="heads">
This is the div to the right
</div><!--End heads-->
</div><!--End PlayerOnline-->
<div id="clear"></div>
</div><!--End boxes-->
CSS:
#boxes{
width: 100%;
overflow: hidden;
clear:both;
margin-top: 10px;
}
#NewsPageContent {
margin-top:10px;
float:left;
width: 63%;
background: #fefefe;
border-radius: 5px 5px 5px 5px;
-moz-border-radius: 5px 5px 5px 5px;
-webkit-border-radius: 5px 5px 5px 5px;
min-height: 100px;
color: #7c7c7c;
font-family: Helvetica, Arial, Verdana, sans-serif;
font-size: 15px;
padding-top: 1px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 10px;
border: 1px solid #a7a6a6;
}
#PlayersOnline{
float:right;
width: 32%;
background: #fefefe;
border-radius: 5px 5px 5px 5px;
-moz-border-radius: 5px 5px 5px 5px;
-webkit-border-radius: 5px 5px 5px 5px;
min-height: 350px;
color: #7c7c7c;
font-family: Helvetica, Arial, Verdana, sans-serif;
font-size: 15px;
padding-top: 1px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 10px;
border: 1px solid #a7a6a6;
}
编辑:我的浏览器中的 HTML:
<div id="boxes">
<div class="NewsPageContent">
<div id="news_title">
<h3>HomieCraft</h3><hr />
<div id="newsbuttons" style="float: right; font-weight: normal;"><a href="http://10.0.0.88/news/article/15">Read</a> | <a href="#">Comment(6)</a></div>
<p style="font-weight: normal; font-size: 9px; margin-top: 1px; margin-bottom: 0px;margin-left: 2px; padding-bottom: 2px;">Published 26-04-2013 23:39 by GudfareN </p>
</div>
<div style="padding-bottom: 6px;" id="news_text">
<p> HomieCraft awwwwyeeeee</p>
</div>
</div><!--End NewsPageContent-->
<div class="NewsPageContent">
<div id="news_title">
<h3>HomieCraft</h3><hr />
<div id="newsbuttons" style="float: right; font-weight: normal;"><a href="http://10.0.0.88/news/article/14">Read</a> | <a href="#">Comment(6)</a></div>
<p style="font-weight: normal; font-size: 9px; margin-top: 1px; margin-bottom: 0px;margin-left: 2px; padding-bottom: 2px;">Published 26-04-2013 23:39 by GudfareN </p>
</div>
<div style="padding-bottom: 6px;" id="news_text">
<p> HomieCraft awwwwyeeeee</p>
</div>
</div><!--End NewsPageContent-->
<div class="NewsPageContent">
<div id="news_title">
<h3>HomieCraft</h3><hr />
<div id="newsbuttons" style="float: right; font-weight: normal;"><a href="http://10.0.0.88/news/article/13">Read</a> | <a href="#">Comment(6)</a></div>
<p style="font-weight: normal; font-size: 9px; margin-top: 1px; margin-bottom: 0px;margin-left: 2px; padding-bottom: 2px;">Published 26-04-2013 23:39 by GudfareN </p>
</div>
<div style="padding-bottom: 6px;" id="news_text">
<p> HomieCraft awwwwyeeeee</p>
</div>
</div><!--End NewsPageContent-->
<div class="NewsPageContent">
<div id="news_title">
<h3>HomieCraft</h3><hr />
<div id="newsbuttons" style="float: right; font-weight: normal;"><a href="http://10.0.0.88/news/article/12">Read</a> | <a href="#">Comment(6)</a></div>
<p style="font-weight: normal; font-size: 9px; margin-top: 1px; margin-bottom: 0px;margin-left: 2px; padding-bottom: 2px;">Published 26-04-2013 23:39 by GudfareN </p>
</div>
<div style="padding-bottom: 6px;" id="news_text">
<p> HomieCraft awwwwyeeeee</p>
</div>
</div><!--End NewsPageContent-->
<div class="NewsPageContent">
<div id="news_title">
<h3>HomieCraft</h3><hr />
<div id="newsbuttons" style="float: right; font-weight: normal;"><a href="http://10.0.0.88/news/article/11">Read</a> | <a href="#">Comment(6)</a></div>
<p style="font-weight: normal; font-size: 9px; margin-top: 1px; margin-bottom: 0px;margin-left: 2px; padding-bottom: 2px;">Published 26-04-2013 23:39 by GudfareN </p>
</div>
<div style="padding-bottom: 6px;" id="news_text">
<p> HomieCraft awwwwyeeeee</p>
</div>
</div><!--End NewsPageContent-->
<div id="PlayersOnline" style="margin-top: 10px;">
<h2>Players Online</h2><hr />
<div id="heads">
</div><!--End heads-->
</div><!--End PlayerOnline-->
<div id="clear"></div>
</div><!--End boxes-->