use*_*896 10 html css width twitter-bootstrap-3
我有一个使用bootstrap 3的简单HTML模板.模板具有以下结构:静态页眉,静态页脚和引导程序类"容器"中的内容.在内容的中间我有bootstrap'w"嗯",我希望它看起来像页眉和页脚.我的意思是我希望它在任何屏幕上都是屏幕的整个宽度.
我创造了轻松的小提琴.
这是一个问题,有没有办法在这个容器内覆盖容器的宽度?
<header>
<div class="container">
<div class="content">
</div>
<div class="well">
</div>
<div class="content">
</div>
</div>
<footer>
Run Code Online (Sandbox Code Playgroud)

div 通过bootstrap在媒体查询中指定container以下max-width默认值.
@media (min-width: 768px){
.container{
max-width:750px;
}
}
@media (min-width: 992px){
.container{
max-width:970px;
}
}
Run Code Online (Sandbox Code Playgroud)
要覆盖它,请在样式表中添加以下样式
//这应该在默认样式中添加,而不是在媒体查询中添加.container {margin:0; 填充:0; }
@media (min-width: 768px){
.container{
max-width:100%;
}
}
@media (min-width: 992px){
.container{
max-width:100%;
}
}
Run Code Online (Sandbox Code Playgroud)
ORIGINAL +最佳实践:始终将.well移动到.container之外,以便使用Bootstrap保持惯用
更新+如果上面不是一个选项:鉴于你不能轻易修改.well样式和/或移动.container外部.container,你最好的选择是JavaScript.在这里,我制作了一个脚本,当窗口的宽度发生变化时,.well会扩展.
http://jsfiddle.net/iamnotsam/E3RQp/1/
这个想法是你想要一个负值.well,.container以便.well在屏幕上扩展.
小智 5
这里有一个更简单的技巧,就像魅力一样起作用:https : //css-tricks.com/full-width-containers-limited-width-parents/
查找:“无需calc()”
的HTML
<header>
<div class="container">
<div class="content"></div>
<div class="well full-width"></div>
<div class="content"></div>
</div>
<footer>
Run Code Online (Sandbox Code Playgroud)
的CSS
.full-width {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
26205 次 |
| 最近记录: |