Elements beyond the bootstrap container

Currently, I am utilizing Bootstrap for my layout design. The specific task at hand is to have two items positioned outside of the container with borders extending all the way to the edge of the screen. To achieve this, I attempted nesting a container within a container-fluid and applying absolute positioning to the elements that need to appear behind the main container. However, the issue arises when the element's width spans the full screen due to inheriting from the parent container-fluid.

.home__border-gray {
        box-shadow: 
          1px 0 0 0 #DCDCDC, 
          0 1px 0 0 #DCDCDC, 
          1px 1px 0 0 #DCDCDC,
          1px 0 0 0 #DCDCDC inset, 
          0 1px 0 0 #DCDCDC inset;
          -webkit-box-shadow: 1px 0 0 0 #DCDCDC, 
          0 1px 0 0 #DCDCDC, 
          1px 1px 0 0 #DCDCDC,
          1px 0 0 0 #DCDCDC inset, 
          0 1px 0 0 #DCDCDC inset;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f2909d9d868186809382b2c6dcc4dcc2">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container-fluid p-0 home__border-gray d-flex flex-row position-relative">
              <div class="h-50 home__border-gray position-absolute">1</div>
              <div class="container p-0">
                <div class="col-12 p-0 home__border-gray d-flex flex-column flex-md-row justify-content-between">
                  <div class="col-md-6 d-flex flex-column p-4 justify-content-center">
                    <h1 class="px-4">Container</h1>
                  </div>
                </div>
              </div>
  <div class="h-50 home__border-gray position-absolute">2</div>
</div>

The challenge lies in ensuring that the lines outside the container extend all the way to the edge of the screen. Expected outcome can be viewed here: https://i.sstatic.net/uZhor.jpg

Answer №1

Here is a suggestion on how you can achieve your desired outcome. It may not be exactly what you're looking for, but it could provide some guidance or inspire you to make adjustments to your code.

Try the following HTML:

<div class="container-fluid">
    <div class="row align-items-start">
        <div class="col-2 text-right">1</div>
        <div class="col-8 text-center d-flex align-items-center">Container</div>
        <div class="col-2">1</div>
    </div>
</div>

And this CSS styling:

div[class^="col-2"] {
    border-bottom: 2px black solid;
}
div[class^="col-8"] {
    height:50px;
    border-left: 2px black solid;
    border-right: 2px black solid;
    font-size: 2.5rem;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to modify form within HTML modal

I am currently facing an issue with editing bootstrap forms. I have set a default and a placeholder value via js, however, the users are unable to change the textfield values. Below is the code for my modal. getData(){ // Pulls data from our API ...

Dynamic element peeks out from behind parent container

When attempting to create an infinite animation for the rocket similar to the one shown here, I encountered an issue where the rocket does not hide beneath the parent div as demonstrated in the example. Instead, the rocket changes position on the Y-axis an ...

Issue with CSS Scroll Bar

I recently incorporated an Accordion and Slideshow feature into my website located at However, when clicking Play on either feature, a scroll bar unexpectedly appears causing the page to shift. I suspect that I may have forgotten to set the height for a ...

Column division shifting beneath the column division that has the greatest height above

I'm currently using a PHP loop to generate and showcase articles (as 'col' divs) from the MySQL database. However, when I use 3 "col-6" divs, the 3rd one ends up moving below the other two instead of staying right next to the first div. Any ...

To make a JavaFX label stand out, simply prepend a vibrant red asterisk at the start of

I'm facing a challenge with my SceneBuilder project. I have developed a scene that consists of several labels, and I want to highlight some of them by adding a red asterisk at the beginning of their text. Unfortunately, I haven't been able to fin ...

trouble centering elements in bootstrap

It appears that when I try to center this image, it is slightly off-center to the right on the page. What could be causing this? It seems like there might be a margin added to the left of the image. <head> <meta charset="utf-8"> ...

Toggle Checkbox Group for Both Multiple and Single Selection Options

Need help with a function to enable only one checkbox for single selection or multiple checkboxes for multiple selection. Use MultipleCheckbox(0) for single selection or MultipleCheckbox(1) for multiple selection. function MultipleCheckbox(elem){ i ...

Tips on centering images of any size within a frame

I am attempting to place an image within a frame. DESIGN #wrapper { border: 2px solid black; width: 600px; height: 400px; overflow:hidden; position: relative; display: inline-block; } img{ p ...

Angular's browser animation feature allows for smooth slide-up animations from the bottom

I have been experimenting with creating a simple animation, and it's working, but in the opposite direction of what I intended. I want the div to open from bottom to top and close from top to bottom. Here is my animation code in Angular: animations: ...

Preventing child elements from inheriting properties in a sequential order

Taking a look at this particular demo: http://jsbin.com/teqifogime/edit?html,css,output In the initial section, we observe that the text color changes simultaneously as the background color transitions, owing to inheriting properties from its parent cont ...

Ways to generate multiple elements using JavaScript

Is there a way to dynamically freeze columns in a table as I scroll it horizontally? I've achieved this statically using JavaScript, but is there a way to indicate the number of columns and achieve the desired style? This is what my JavaScript code c ...

The scrollable dialogue disrupts the background's ability to flex and grow

My page layout is pretty simple: <main> <header>Header</header> <section>Content</section> <footer>Footer</footer> </main> <dialog>Dialog</dialog> In terms of CSS, here's how it ...

Fixing issues with internal web page connections (#x) present in the HTML code (href="#x" id="x")

Can anyone come up with a brilliant solution as to why my internal links are not functioning properly on a webpage? I've coded the HTML with the usual <a href="#link"><button>Some Text</button></a> .... bunch of content .... & ...

Tips for expanding the maximum width of a container using bootstrap4

Having trouble increasing the maximum width of my container. How can I adjust the width in the source code? I've attempted changing the width size in the bootstrap-grid.css file. The Element Inspector lets me change the max-width. Any tips on modify ...

What steps can I take to ensure that this list remains fixed at the bottom of the page?

Looking to have this content positioned at the very bottom of my webpage without any empty space below it. I'm having trouble applying the usual CSS to achieve this. .footer li{ display:inline; } <footer> <div cla ...

Table designed using the Flexbox layout model

I am looking to create a table with multiple columns that can handle dynamic data. The challenge is that using the base <table> element would cause the column width to change when the content changes and I also need the ability to hide columns using ...

Adjust the width of the dropdown menu to match the width of the textbox when using

I am looking to create a dropdown width that matches the width of a textbox using bootstrap techniques. https://i.sstatic.net/kKrsz.png NOTE: The size should adjust automatically based on the width of the textbox, not relative to the page width. < ...

Set focus on Bootstrap modal when closing the popup near the input field within the body

Hello fellow members of the Stack Overflow community! I'm trying to make sure that when users click on a Bootstrap modal window, the input field automatically gets focused. I've attempted the code below but it's not working as expected. Any ...

Every time I insert the SVG logo onto the bootstrap navbar, the formatting mysteriously alters

I'm facing an issue with my svg logo on the navbar - half of it is formatted correctly while the other half is not. Additionally, there is a discrepancy in how it appears on Safari and Chrome. I exported this svg file from Adobe Illustrator and incorp ...

Ensuring the scroll bar is consistently positioned at the bottom

I'm currently working on a chat application using Vue.js and I'm facing an issue with the scroll bar. Despite using overflow: auto; and customizing the scroll bar, it doesn't automatically scroll to the bottom whenever a new message is sent. ...