Creating responsive Twitter Bootstrap layouts that include nested containers with beautiful background images

I am currently working on nesting containers using Twitter Bootstrap in order to achieve the layout shown in this screenshot. The height of the bubble image in the PSD is 404px, and I need it to be responsive across all devices while scaling appropriately without dominating the screen. Can someone please guide me on how to perfect the CSS for this?

So far, I have attempted to use Bootstrap to accomplish this but the result is not as desired, especially with getting the containers right. While I've come across advice that containers should not be nested in bootstrap, they "can be" under certain circumstances.

https://i.sstatic.net/MApA1.png

Despite my efforts to nest containers, I have been unable to replicate what is depicted in the screenshots using Bootstrap.

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/style.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <title>Page Title</title>
</head>
<body>
    <div class=".container-fluid">
        <div class="row">
            <div class="col-lg-12 top">
                TOP TRENDING STORY FOR AUGUST 21, 2019
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12 bg-top">

                    <div class="container">
                        <div class="row">
                            <div class="col-md-6">

                                test 1

                            </div>

                            <div class="col-md-6">

                                Test 2

                            </div>

                        </div>
                    </div>

            </div>
        </div>
    </div>
</body>
</html>

CSS

.top{

    background-color: #d42222;
    color:#FFFFFF;
    font-size:23px;
    text-align: center;

}

.bg-top{

    background:transparent url('../images/background-top.png') no-repeat center center /cover;

}

Answer №1

To achieve the desired look, some styling adjustments are necessary. It is recommended to review and potentially override the default left and right margins set by Bootstrap's .container class. In order to closely match the image you provided, additional top and bottom margins have been included.

Below is a fully functional snippet of code:

.redBanner {
  background: red;
}

.redBanner p {
  margin-bottom: 0;
}

.myExternalContainer {
  background-image: url("https://www.akberiqbal.com/Jumbo.jpg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-color: lightblue;
  padding-bottom: 5%;
}

.myInternalContainer {
  margin-top: 10%;
  margin-bottom: 10%;
}

.innerMostContainer {
  margin: 10%;
}

.innerMostContainer button {
  width: 100%;
}

.container {
  background: #fff
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">


<div class="container-fluid myExternalContainer">
  <div class="row">
    <div class="col-lg-12 top redBanner">
      <p class="text-center">TOP TRENDING STORY FOR AUGUST 21, 2019</p>
    </div>
  </div>
  <div class="container myInternalContainer">
    <h3 class="text-center"> medicare</h3>
    <div class="row">
      <div class="innerMostContainer">
        <div class="row">
          <div class="col-lg-12 bg-top">
            <img src='https://www.akberiqbal.com/src/images/LinkedIn4.png' class='img-fluid' />
            <div class="row">

              <div class="col-6">
                Author Name
                <br/> Published date
              </div>
              <div class="col-6">
                <button type="button" class='btn btn-primary'>Read time</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

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

Incorporating HTML code from a Google Sheet cell and displaying it in a separate cell for visibility

In my Google Sheet, I am trying to extract HTML code from Column F in Tab2 and display it so that it appears in Column G of Tab 2 on the same row. For example, I have the following HTML code in cell F6 and I want it to be displayed in G6. Normally, the co ...

Generating table columns using *ngFor method

Trying to create a table in Angular and wondering how to generate table columns using something like *ngFor. I currently have two lists: Data: [ 0: data: [ 0: 0 1: 4 2: 4 3: 3 4: 5 5: 1 ] id: 49 label: "Label_1" 1: data:[ 0: 5 1: 0 2: 1 3: 5 4: 0 ...

The text's height adjusts when a unicode character is inserted

I'm working with an HTML element that has text content. The font is set to sans-serif in the CSS, and the text is updated through JavaScript. Sometimes, the text contains just ASCII characters, but other times it includes the "➜" character. You can ...

Is there a more effective method for concealing arrows while scrolling?

I'm attempting to conceal the arrow that appears above the selected header, as depicted below. https://i.stack.imgur.com/wyxdF.png While scrolling, I aim to hide the arrow that appears on the header Company, especially when the first column is sticky ...

Can the <br> tag affect the layout in terms of horizontal space?

I am perplexed by the fact that it displays two lines vertically separated with a br tag differently than two lines vertically separated with the first line acting as a block level tag. For example, see this code snippet: https://jsfiddle.net/qzgeassf/ ...

Is there a way to make all Bootstrap column heights equal using only jQuery?

I am currently working on matching the heights of two columns without using an existing library like match-height.js. In this specific case, I have a row with 2 columns where the first column contains a centered black square and the second column contains ...

Angular 9 does not update Bootstrap 4 colors

I created a custom scss file called modified-bootstrap.scss to customize bootstrap variables $theme-colors: ( "primary": #84329b, "secondary": #02bceb ); @import "node_modules/bootstrap/scss/bootstrap.scss"; // also tried using a relative path Next, ...

Is there a way to manipulate the appearance of a scroller using JavaScript?

I'm intrigued by how fellow front-end developers are able to customize the scrollbar shape on a webpage to enhance its appearance. Can anyone guide me on using JavaScript to accomplish this? ...

Conic-Gradient causing an intriguing visual anomaly

When attempting to create a simple conic-gradient using CSS, I've noticed a peculiar horizontal line that keeps appearing. These lines seem unpredictable and sometimes disappear when the window is resized. div { width: 101.5px; height: 10 ...

Utilizing document.write to switch up the content on the page

Every time I attempt to utilize document.write, it ends up replacing the current HTML page content. For instance, consider this HTML code: <body> <div> <h1>Hello</h1> </div> and this jQuery code: var notif = document. ...

Exploring Data in a Tree View Format on a PHP Website

Looking for advice on displaying categories and corresponding subcategories on the left side of my website (built using Php and Javascript). I would like the tree to be movable, similar to the functionality featured on this link: Any suggestions on how I ...

Generate a biscuit within a text field while typing, then transmit it

Is it possible to create a cookie in a textarea onkeypress and then send the cookie to a result page? Essentially, if the user types B or R in the textarea, can a cookie be created and sent to a result page? Below is the code snippet for each page: Exerci ...

Show and conceal columns in HTML with the help of JavaScript

I need help with a webpage where I want to display a table with 2 columns and two rows (header and body). My goal is to use JavaScript to control the visibility of these 2 columns. The decision to show or hide the columns should be based on the values ...

Connecting radio buttons to data in Vue using render/createElement

How do you connect the value of a selected radio button to a specific variable in the data object within a Vue application when using the render/createElement function? ...

Verify the minimum value of the variable total cost and trigger an alert message if it is below the specified minimum value

Hello, I have a question regarding implementing a restriction on the checkout process for a shopping cart. I want to prevent users from checking out if the total cost is less than £50.00 and instead display a JavaScript alert message. As someone who is n ...

Would parallax stars be overwhelming for a webpage?

I'm a newcomer to the world of web development and I have an idea to make stars move across my website. However, I'm concerned about whether this might be too much for a simple website to handle. Is there a way to optimize the code? const canvas ...

SVG Filter: The image is not completely covered by a width and height of 100%

Here's a basic SVG Filter. Click the example below to toggle the appearance of the filter: var image = document.querySelector('image'); var url = 'https://i.picsum.photos/id/202/2 ...

Create a tic tac toe game board using CSS styling for a table

I am considering creating a tic-tac-toe game using jQuery and PHP. I would like to customize the design of the game board, which is represented by an HTML table, by applying CSS styling. However, I am struggling to find CSS properties that would allow me t ...

moving the array generated on the HTML page to a different page

Can anyone help me with transferring an array from one page to another? I have a list of names in the code below and I want to be able to access and print this array on another page using JavaScript. Your assistance is greatly appreciated! <html> ...

Implementing a pop-up notification at the center of the display for empty fields

I am currently working on a task that requires me to display a pop-up message at the top-middle of the screen stating "please fill in all fields before submitting". This custom box should be stylable using CSS. Although the solution seems simple, I am str ...