question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Container Full Width Override

See original GitHub issue

Hey,

I’m looking to override the parent container by making a certain div full-width (touch both sides of the screen).

I initially did a StackOverflow search for solutions and whilst some provide a sort-of solution, I’m looking for something that fully works and is responsive.

Ideally, you’d be able to have this markup:

<div class="container">
    <div class="container-full">
        <p>I'm full width</p>
    </div>
</div>

built-in to Bootstrap. The reason I think it’s a valid feature request is that, frameworks like Symfony, WordPress, Magento etc. etc. break up all of their files into templating files, e.g. header.phtml, footer.phtml. This causes an issue with coding up designs due to setting a generic container after your <header></header> tags to keep everything generally in a container, however, there may be the desire for a full-width feature image.

My current code to try and achieve this is:

<div class="container">
    <img src="https://www.legendaryrides.eu/wp-content/uploads/2017/10/top-banner.jpg"
             class="img-fluid" />

    <div class="container-full">
        <div class="contents">
            <img src="https://www.honda-mideast.com/en/-/media/honda/bikes/africa-twin-adventure-sport/perfomec-banner.jpg"
                 class="img-fluid" />
        </div>
    </div>

    <img src="https://www.digitalgames.ro/images/2015/06/For-Honor-Logo-HD.jpg" class="img-fluid" />
</div>

With this CSS:

div.container-full {
    background: #ccc;
    left: 50%;
    margin-left: -50vw;
    position: relative;
    width: 100vw
}

and this JS:

function fullRowResize()
{
    let bodyWidth = $('body').width(),
         fullContainer = $('.container-full');

    fullContainer.css('width', (bodyWidth));
    fullContainer.css('margin-left', ('-'+ (bodyWidth / 2) +'px'));

    return false;
}

$(window).on('resize', fullRowResize());

This kind of works but not as dynamically and responsive as it should be… is there anything currently in Bootstrap 4 that achieves my goal?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
florianlacreusecommented, Dec 5, 2018

@ibash Sorry but it doesn’t look to a valid feature request to me too. 3 possible options in your case:

  • Move down div container in index.php, index2.php, etc. and then use either .container or .container-fluid.
  • I’m not familiar with PHP framework, however good Java framework UI give the opportunity to use variables for any attributs of any html tags.
  • Keep with custom css code on your own but Bootstrap can not be involved, I guess.

Good luck with your layout.

0reactions
ibtreycommented, Dec 5, 2018

@ysds

It seemed almost there - though large images scale outside the container. Seems like to use this solution you’d sorta have to build your own css lib to handle everything, and then, at that point - what’s the point of using Bootstrap…?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to override parent containers width property in CSS
Do this, use padding and margin (margin-left and margin-right and padding-left and padding-right) to achieve this.
Read more >
Overriding Max Width Set by Container - GeneratePress
I need a container with 100% width of the document/window/page. Try adding a width: 100%; to that CSS.
Read more >
Full Width Containers in Limited Width Parents - CSS-Tricks
The issue is: how do we make a full-browser-width container when we're inside ... above this in the CSS and let this override...
Read more >
Creating full width (100% ) container inside fixed ... - Coderwall
Some times we need to add a full width containers (which spans 100% of window) inside a container which has a fixed width...
Read more >
How to Override Material UI Container Width - Muhi Masri
Learn how Material UI container width works including two simple techniques for customizing and overriding the container width.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found