bootstrap 3 full width image and div in container

后端 未结 4 1434
情书的邮戳
情书的邮戳 2021-01-19 11:07

I\'m trying to set some divs to width: 100% on Twitter Bootstrap 3 (including no paddings or margins).

JSfiddle: http://jsfiddle.net/rq9ycjcx/

H

相关标签:
4条回答
  • 2021-01-19 11:22

    Use <div class="container-fluid">. As per Bootstrap Docs: Use .container-fluid for a full width container, spanning the entire width of your viewport.

    There is 0 padding on container-fluid.

    In your code you have what appears to be body content in your header and you also have a div class="container" outside of your header and footer. This is not correct, you should have your container/container-fluid inside of your body. Also for your header you should use <nav="nav navbar-nav">.

    Updated Fiddle

    0 讨论(0)
  • 2021-01-19 11:32

    A simple way would be to remove the <div class="col-md-12">...</div> and add your content directly inside the row tag. The row tag removes the left & right gutters, whereas the cold-md-12 essentially adds the gutters back in.

    The Bootstrap 3 documentation says that for single full width items you dont need any markup, eg just wrap it in <p> tags. However this will show the 15px gutters due to the page markup. So by simply adding in the row tag and placing your content directly inside this you will get 100% width content and be compliant with the BS3 documentation.

    0 讨论(0)
  • 2021-01-19 11:37

    As suggested above, you can create a helper class

    .padding-0 {
        padding: 0;
    }
    

    and apply it to any HTML elements for which you need a padding reset. So in your case, it would look like this:

    <div class="row">
        <div class="col-md-12 padding-0">
            <img src="http://placehold.it/350x150" />
        </div>    
    </div> 
    

    For the second problem, set height of .gray class to auto :

    @media () {
        .gray {
            height: auto;
        }
    }
    

    Note: You could also remove line-height: 80px, it's optional :)

    http://jsfiddle.net/rq9ycjcx/8/

    0 讨论(0)
  • 2021-01-19 11:44

    There is no "right" way to do that in Bootstrap 3. It means you have to reset padding for the exact column.
    You can create a class such as this one:

    .col-md-12.resetPadding { padding:0px }
    

    About Main page > page disappearing, I don't see this problem on my browsers (tested on Chrome and FF), but you have line-height: 80px there and as you said your breadcrumbs div has height: 80px;, so try to reduce line-height property and see how it works.

    0 讨论(0)
提交回复
热议问题