简体   繁体   English

在div容器HTML / CSS中填充

[英]Padding in div container HTML/CSS

I´m trying to make the image below to fit the whole div, meaning that the background image should take the whole space and I shouldn't see the green color. 我正在尝试使下面的图像适合整个div,这意味着背景图像应占据整个空间,而我不应该看到绿色。 Unfortunately I can´t find a way to do it. 不幸的是,我找不到办法。

 #imagecontainer { background: url("http://3.bp.blogspot.com/_EqZzf-l7OCg/TNmdtcyGBZI/AAAAAAAAAD8/KD5Y23c24go/s1600/homer-simpson-1280x1024.jpg") no-repeat; border: 1px solid; background-size: cover; } 
 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <div class="container no-padding" id="maincontent" tabindex="-1"> <div id="imagecontainer" class="row"> <div class="col-lg-12"> <img class="img-responsive" src="img/profile.png" alt=""> <div class="intro-text"> <h1 class="name">Start Bootstrap</h1> <h1 class="name">Start Bootstrap</h1> <h1 class="name">Start Bootstrap</h1> <hr class="star-light"> <span class="skills">Web Developer - Graphic Artist - User Experience Designer</span> </div> </div> </div> </div> 

在此处输入图片说明

Many thanks! 非常感谢!

Your using container , use container-fluid to make it full width. 您使用的container ,请使用container-fluid使其全宽。 Here is a demo 这是一个演示

The #maincontent div has a padding, a positive margin and a width set in pixels; #maincontent div具有填充,正边距和以像素为单位设置的宽度; and the #imagecontainer has a negative margin. #imagecontainer的边距为负。

This is because that's the way Bootstrap deals to accomodate items in its grid. 这是因为这是Bootstrap处理其网格中的项目的方式。

You could considerate using a fluid Jumbotron instead to use the full width and take the necessary vertical space for your content. 您可以考虑使用流动的Jumbotron,而不是使用整个宽度并为内容保留必要的垂直空间。

This could be of help: https://v4-alpha.getbootstrap.com/components/jumbotron/ 这可能会有所帮助: https : //v4-alpha.getbootstrap.com/components/jumbotron/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM