1

由於某些原因,.container元素未在IE8中居中。下面是最少的代碼來演示這個問題我遇到:Bootstrap.container未在IE8中居中

<!DOCTYPE html> 
<html><head> 
<meta charset="utf-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>Title</title> 
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" type="text/css"> 
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> 
<!--[if lt IE 9]> 
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> 
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script> 
<![endif]--> 
</head><body> 
    <div id="content" class="container"> 
     <div class="row"> 
      <div class="col-xs-12"> 
       <p>Test</p> 
      </div> 
     </div> 
    </div> 
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
    <script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> 
</body></html> 

在線演示:http://tinyurl.com/ndn64tz

+0

演示鏈接看起來不錯,在我的IE8側。 –

+0

在我的IE8瀏覽器上,文本「測試」全部位於視口的左側。 – Matthew

+0

試試我發佈的答案..應該工作..設置所需的高度.. –

回答

2

我不知道是什麼問題,當我嘗試它在我的機器上顯示以及(IE11與用戶代理更改).. 這招應該工作。(覆蓋容器

.container{ 
    width:1020px; //or your desired width 
    margin:0 auto; 
    padding:10px; 
} 

根據需要進行適當的修改。

備選答案:

包含該庫中的所有樣式表被稱爲後..

https://github.com/scottjehl/Respond

這將使CSS3媒體查詢在舊的瀏覽器。

,並添加備選答案的<meta http-equiv="X-UA-Compatible" content="IE=edge">

來源:IE8 issue with Twitter Bootstrap 3

0
<!DOCTYPE> 
<html> 

<!--[if IE 8]><center><![endif]--> 
<section id="first" class="container"> 
    <div class="row"> 
    <!--[if IE 8]></center><![endif]--> 
    <div class="col-lg-12">Helo World</div> 
    </div> 
</section> 

只需添加中心標籤