3

我正在为我的网站制作一个简单的主页,但我想让井均匀分布。我可以将左对齐和右对齐,但我似乎无法让中间位置始终保持在页面的中心。我已经尝试了很多东西,但它们都不起作用,看看我的网站,看看我想要做什么,水井位于图像滑块下方。这是我已经完成的代码,但是 CSS 是默认的 bootstrap min css,对颜色进行了一些调整。

<div class="container">
 <div class="row">
  <div class="col-lg-4 well" style="margin-left: 10px !important; width: 330px;
       margin-right: 10px; padding: 4px !important; min-height: 330px; ">
     <center>
       <img style="height: 135px;" src="img/ts.png" />
       <h3>TeamSpeak 3</h3>
           <br />
       <p>Chat with us on our TeamSpeak at: <br />
        <b><a href="ts3server://ts.clustermc.net">ts.clustermc.net</a></b>
        <br /> So, come have a wonderful conversation with us!</p>
     </center>
  </div>
  <div class="col-lg-4 well" style="margin-left: 10px !important; width: 330px;
       margin-right: 10px; padding: 4px !important; min-height: 330px; ">
     <center>
       <img style="height: 135px;" src="img/wool.png" />
       <h3>Cluster MC</h3>
       <div class="progress" style="margin-bottom: 7px; width: 200px;">
         <div class="progress-bar progress-bar-success" style="width: 2.0%;">
         </div>
         <div class="progress-bar progress-bar-danger" style="width: 98.0%;">
         </div>
       </div>
       <p style="margin-top: -27px; color: white; font-weight: bold;">
           3 Online</p>
       <br />
       <p>Start collecting your ClusterCredits now at:<br />
         <b>play.clustermc.net</b></p>
    </center>
 </div>
 <div class="col-lg-4 well" style="margin-left: 10px !important; width: 330px;
      margin-right: 10px; padding: 4px !important; min-height: 330px; ">
   <center>
     <img style="height: 135px;" src="img/forums.png" />
     <h3>Community Forums</h3>
     <br />
     <p>Come and talk to some of our memers and staff at the forums! <br />
       <b><a href="http://clustermc.net/forums">www.clustermc.net/forums</a>
       </b>
       <br />We dont bite, we promise!</p>
   </center>
 </div>
 </div>
 </div>

抱歉布局不好,我是编码初学者,我想学习:)

4

2 回答 2

7

这是更新的代码。我已经嵌套了一个带有类的 div,因为它在与 col-lg-4 一起使用时会重叠。请检查以下代码:

<div class="container">
  <div class="row">
     <div class="col-lg-4">
       <div class="well" style="height: 330px; width: 330px;">
          <center>
            <img style="height: 135px;" src="img/ts.png"/>
            <h3>TeamSpeak 3</h3>
            <br/>
            <p>Chat with us on our TeamSpeak at: <br/>
              <b><a href="ts3server://ts.clustermc.net">
                    ts.clustermc.net</a></b>
              <br/>
               So, come have a wonderful conversation with us!
            </p>
          </center>
         </div>
        </div>
        <div class="col-lg-4">
         <div class="well" style="height: 330px; width: 330px;">
           <center>
     <img style="height: 135px;" src="img/wool.png"/>
             <h3>Cluster MC</h3>
             <div class="progress" style="margin-bottom: 7px; width: 200px;">
             <div class="progress-bar progress-bar-success" 
                  style="width: 2.0%;"></div>
             <div class="progress-bar progress-bar-danger" 
                  style="width: 98.0%;"></div>
          </div>
             <p style="margin-top: -27px; color: white; font-weight: bold;">
                3 Online
             </p>
             <br/>
             <p>Start collecting your ClusterCredits now at:<br/>
                <b>play.clustermc.net</b></p>
          </center>
         </div>
        </div>
        <div class="col-lg-4">
          <div class="well" style="height: 330px; width: 330px;">
             <center>
               <img style="height: 135px;" src="img/forums.png"/>
               <h3>Community Forums</h3>
               <br/>   
               <p>Come and talk to some of our memers and staff at the forums
               <br/>
           <b><a href="http://clustermc.net/forums">
                     www.clustermc.net/forums</a>
               </b><br/>
                    We dont bite, we promise!</p>
             </center>
            </div>
        </div>
    </div>
</div>
于 2013-10-24T07:41:33.290 回答
0

看起来你的三个“好”的 div 已经在页面中间了?

因为所有东西都在里面<div class="container">,所以它是用于将内容集中在页面上的引导类。根据http://getbootstrap.com/2.3.2/scaffolding.html#layouts

注意:您似乎错过了</div>课程container的最终结局

我不是 100% 确定你遇到了什么问题。也许提供您想要实现的屏幕截图?

于 2013-10-23T23:21:03.240 回答