2016-07-16 48 views
0

SO上的第一次。Div不佔滿全寬?

我搜索了四周,只看到人們說「看看父母」。 我的問題有點不同。

這裏是我的演示站點 - http://falconsnest.cf(Django框架)

這裏的GitHub的 - github.com/Sir-Lagsalot/FalconsNest

我的問題是與格 「容器」。它不適合整個頁面,它只是奇怪地坐在偏左的中心位置。我該如何解決?

段:

@import 'http://falconsnest.cf/static/webapp/css/project/custom.css': 
 
@import 'http://falconsnest.cf/static/webapp/css/bootstrap.min.css': 
 
    @import 'http://falconsnest.cf/static/webapp/js/jquery-3.0.0.min.js': 
 
    @import 'http://falconsnest.cf/static/webapp/js/project/headerjs.js':
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
 
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
 
<script src="http://falconsnest.cf/static/webapp/js/project/headerjs.js"></script> 
 
<script src="http://falconsnest.cf/static/webapp/js/jquery-3.0.0.min.js"></script> 
 
<link href="http://falconsnest.cf/static/webapp/css/bootstrap.min.css" rel="stylesheet"/> 
 
<link href="http://falconsnest.cf/static/webapp/css/project/custom.css" rel="stylesheet"/> 
 

 
<body> 
 

 
<div class="container"> 
 
    <button type="button" class="btn btn-primary btn-lg raised" data-toggle="collapse" data-target="#Signin"><span>Sign In!</span></button> 
 
    <div id="Signin" class="collapse"> 
 

 
     <div class="loginbar"> 
 
     <h1>LOGIN</h1> 
 
     </div> 
 
     <div class="prompt"> 
 
     <form action=forms.py method="POST"> 
 
      <input type='hidden' name='csrfmiddlewaretoken' value='6olNNouNeySQqSmiKExapeXe69tyAwZP' /> 
 
      StudentID:<br> <input class="form-control" type="text" name="username"><br> 
 
      Password:<br> <input class="form-control" type="password" name="password"> 
 
      <p></p> 
 
      <font size=2px> Don't have an account? <a href="/register">Register here!</a> <p></p></font> 
 
      <input type="submit" value="Submit"> 
 
     </form> 
 
     </div> 
 

 
    </div> 
 
</div> 
 
    </body>

這應該可以更清楚:

I want the div to cover the whole page. It's not. I've tried changing the class and setting the width to 100%. Doesn't work, but I can do thing like 140$, but that's not elegant and not dynamic to different screen sizes.

+1

發佈重現問題的最小工作Stack代碼段 – LGSon

+0

容器流體適合整個頁面。 – Saini

+0

我沒有看到有什麼問題: -/ –

回答

0

使用容器流體而不是容器類。

由於Bootstrap已經定義了容器類具有值並且容器流體類具有其自己的值的值,所以它顯示爲偏離中心。

這些值根據最佳視圖進行調整。

容器流體類有一些左右邊距值定義會導致您的工作出現問題。

雖然容器類也有一些非常少量的邊界定義。

+0

Django是無稽之談。在我的代碼中找不到,只能在頁面源代碼中找到。 –

0

其中之一將對其進行排序: 1)添加全寬 -

.yourDiv { 
    Width: 100%; 
} 

2)刪除邊距和填充

.yourDiv { 
    margin: 0px; 
    padding: 0px; 
} 

3)檢查是否有任何元素不會導致你的div來向左移動,而不是成爲全寬

如果這些不工作,請提供一些代碼和你的div如何放置的圖片。

+0

檢查Django是否沒有添加任何額外的div – RyanM

+0

嘗試添加「width:100%!important;」到您的CSS – RyanM

0

哈哈,我的壞。對不起,你們誤導了你們。我發現bootstrap製作了div 1570px,而不是100%。當我把它變回100%時,它適合那個col-2。我意識到col-2來自另一個html文件。咩。

感謝您的幫助!