2017-06-14 65 views
0

我正在这个简单的页面上工作,我正在寻找使用引导代码只在中心(如果可能)这是我到目前为止。我尝试使用col-xl-offset-4,但无法正常工作。我怎么能使用引导中心这个HTML页面

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> 
 
<div class="container"> 
 
    <div class="jumbotron"> 
 
    <div class="row vertical-center-row"> 
 
     <div class="col-xl-6 col-xl-offset-4"> 
 
     <h1 class="text-primary text-center">Marcell Treville</h1> 
 
     <h3 class="text-center"><em>This is a tribute page for the legendary painter "Marcell Treville"</em></h3> 
 
     <div class="thumbnail"> 
 
      <img src=""> 
 
      <p>this is some text describing the image</p> 
 
      <h2>Here's a timeline of Dr. Marcell Treville</h2> 
 
      <ul> 
 
      <li><strong>1995</strong> item one</li> 
 
      <li>item one</li> 
 
      <li>item one</li> 
 
      <li>item one</li> 
 
      <li>item one</li> 
 
      <li>item one</li> 
 
      </ul> 
 
     </div> 
 
     </div> 
 
    </div> 
 
    </div> 
 
</div>

+0

你是什么意思的居中?水平或垂直居中? –

+0

你想要居中什么?整个HTML页面还是只是容器?你想把它放在另一个容器中还是仅仅与屏幕相关? –

回答

0

喜无需使用偏移。 尝试添加 “文本中心”,该div

HTML

<div class="col-xl-6 text-center"> .... </div> 

希望这有助于

0

对于引导V4,只需使用row justify-content-center会做的伎俩。

REF:https://v4-alpha.getbootstrap.com/layout/grid/

enter image description here

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"> 
 
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script> 
 

 
<div class="container"> 
 
    <div class="jumbotron"> 
 
    <div class="row justify-content-center"> 
 
     <div class="col-6"> 
 
     <h1 class="text-primary text-center">Marcell Treville</h1> 
 
     <h3 class="text-center"><em>This is a tribute page for the legendary painter "Marcell Treville"</em></h3> 
 
     <div class="thumbnail"> 
 
      <img src=""> 
 
      <p>this is some text describing the image</p> 
 
      <h2>Here's a timeline of Dr. Marcell Treville</h2> 
 
      <ul> 
 
      <li><strong>1995</strong> item one</li> 
 
      <li>item one</li> 
 
      <li>item one</li> 
 
      <li>item one</li> 
 
      <li>item one</li> 
 
      <li>item one</li> 
 
      </ul> 
 
     </div> 
 
     </div> 
 
    </div> 
 
    </div> 
 
</div>

+0

@miatech是否解决了您的问题? –

0

您希望通过3到偏移,因为这将加起来12.如果你通过四个偏移你将会有4个'空'col,接下来的6个div,以及其后2个'空'cols。你想要的是3-6-3。你现在拥有的是4-6-2。

+0

但仍然显示文本左...甚至没有移动 – miatech

+0

我只注意到你正在尝试使用引导程序3和col-xl。 Bootstrap 3只使用col-lg。 Bootstrap 4将会有一个col-xl。 – Dan

+0

你可以做一个谷歌添加你自己的xl类,这很简单。 – Dan

相关问题