Creating a dynamic webpage with flexible design and interconnected containers using the Bootstrap framework

Creating a responsive layout with nested divs using Bootstrap Check out my HTML code below:

<div class="container-fluid" style="height: 350px;">
    <div class="row-fluid clearfix" style="height: 100%">
        <div class="col-md-9 column" style="height: 100%;">
            <div class="row clearfix" style="height: 50%;">
                <div class="col-md-4 column" style="height: 100%;background-color: red"></div>
                <div class="col-md-4 column" style="height: 100%;background-color: green"></div>
                <div class="col-md-4 column" style="height: 100%;background-color: blue"></div>
            </div>
            <div class="row clearfix" style="height: 50%;">
                <div class="col-md-12 column" style="height: 100%;background-color: pink"></div>
            </div>
        </div>
        <div class="col-md-3 column" style="height: 100%;background-color: yellow"></div>
    </div>
</div>

Output:


When you increase the browser screen width, the green and blue colored divs seem to be missing.

My expected output:


I would appreciate your assistance in resolving this issue.

Answer №1

To prevent elements from overlapping, it is important to also define classes for mobile view. One way to do this is by using the following example:

col-xs-12 col-md-4 column

For a live demonstration, check out the bootply here

Answer №2

The solution is working perfectly now, all you need to do is remove the clearfix class from the row. Here is the corrected code:

   <div class="container-fluid" style="height: 350px;">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<div class="row-fluid">
    <div class="col-md-9 column">
        <div class="row">
            <div class="col-md-4 column" style="height: 150px;background-color: red">
            </div>
            <div class="col-md-4 column" style="height: 150px; background-color: green">
            </div>
            <div class="col-md-4 column" style="height: 150px; background-color: blue">
            </div>
        </div>
        <div class="row">
            <div class="col-md-12 column" style="height: 150px; background-color: pink">
            </div>
        </div>
    </div>
    <div class="col-md-3 column" style="background-color: yellow; height: 300px">
    </div>
</div>
</div>

Answer №3

Ramesh Gupta Hello, I have optimized your code to keep only the essential parts required for functionality.
Give it a try and let me know how it goes.
This revised code aligns the pink block properly with the rest of the elements.

To view the enhanced version, click on this link: Fiddle. It's easier to adjust the size there.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Bootstrap Starter Template</title>

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

<style>
body {
  padding-top: 50px;
}
.space {
  margin-top: 5%;
  margin-bottom: 5%;  
}    
    
.block-a {
  height: 350px;  
}
.block-b {
  height: 175px; 
}    
.block-red {
  height: 175px;
  background-color:#ff1000;  
}
.block-darkgreen {
  height: 175px;   
  background-color: green;  
}
.block-blue {
  height: 175px;   
  background-color: blue;  
}
.block-pink {
  height: 175px;   
  background-color: pink;  
}
.block-darkyellow {
  height: 350px;   
  background-color: gold;
}     
</style>

</head>

<body>

    <nav class="navbar navbar-inverse navbar-fixed-top ">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand " href="#">Project name</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
          <ul class="nav navbar-nav navbar-right">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#about">About</a></li>
            <li><a href="#contact">Contact</a></li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </nav>

<div class="container col-lg-12 space"></div>
    
<div class="container-fluid">
    <div class="row-fluid col-md-9 block-a">
        <div class="col-xs-12 col-sm-12 col-md-4 block-red"></div>
        <div class="col-xs-12 col-sm-12 col-md-4 block-darkgreen"></div>
        <div class="col-xs-12 col-sm-12 col-md-4 block-blue"></div>
        <div class="col-xs-12 col-sm-12 col-md-12 block-pink"></div>
    </div>
    <div class="row-fluid col-md-3 block-a">
        <div class="col-xs-12 col-sm-12 col-md-12 block-darkyellow"></div>
    </div>
</div>    
    
  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    
</body>
</html>

Answer №4

It is important to note that the red div will be displayed prominently in this scenario. This is due to the fact that the parent div has a specified height of 50%, and all three child divs have a height of 100% each. Consequently, the red div, being the first one, will occupy the entire height available. To address this issue, a potential solution would involve assigning a height of 33.33% to each of the three divs when a certain breakpoint is reached, like so:

@media(max-width: 767px) {
  .col-md-9 .col-md-4 {
    height: 33.33%;
  }
}

Prior to implementing this adjustment, it may be advisable to assign more specific classes to the respective div elements.

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

What is the method to make a String bold when sending it through a messaging service?

Here is the structure of my service: import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root', }) export class MessageService { messages: string[] = []; add(message: string) { this.messages.push(message); ...

JSON failing to show all values sent as a string

In a div element there is a table with 3 rows, a textarea, and a button. The JSON data populates the first 3 rows correctly but the textarea remains blank. My goal is to display the previous record from the database in the textarea. function ChangeLoadin ...

Guide on transforming Color to HTML color with .NET Standard 2.0

How can I convert a color to HTML color in .NET Standard 2.0? Thank you. Is there a way to achieve the same functionality in .NET Core? System.Drawing.ColorTranslator.ToHtml(color); Or is this only available in DotNet Framework? ...

Failure of event watcher on dynamically updated content

Any help would be greatly appreciated! :) I am currently using JavaScript to dynamically add fields to a document, but I have noticed that the event listener only works on predefined fields. For instance, in the code snippet below, the 'lozfield&apo ...

How to use CSS to add a pseudo element to a table and position it outside of the parent's boundaries on the left

I am currently utilizing the "ag-grid" data-table library (along with Angular 2, although the framework is not crucial) which highlights a selected row (using the default class .ag-row) by adding the class .ag-row-selected to it. Each row contains numerous ...

Looking to achieve a stretch-auto-auto column layout in Bootstrap 4 - how can this be done?

Essentially, I am looking for something similar to this: https://i.sstatic.net/ss3Ir.png Can this layout be achieved using columns instead of floats? <div class="clearfix"> <div class="float-left"><button class="rounded btn btn-outline ...

"Within the node.js framework, the search/query section of the URL appears

I am currently working on a website (client + server) that both operate from the same machine. Despite not encountering any issues in Chrome's developer tools, I am struggling to identify the source of a problem. My dilemma is with trying to POST a s ...

Vertical alignment to the top is not possible for Inline-Block divs

When attempting to create a responsive 'grid' with two (div) panels that appear side by side on wide screens and stacked on top of each other on smaller screens, I came across an issue where the divs align at the bottom when displayed as 'bl ...

Exploring the Application of CSS Styles in Selenium

I need help with a webpage that contains a configurable field. The values of this field can be set through a configuration panel, and it can be marked as required by checking a checkbox which applies a specific style to the field label. My question is, how ...

Hovering over rounded corners is being blocked by transparent areas

I have a setup that resembles the following: http://jsfiddle.net/NhAuJ/ The issue arises when hovering near the edges of the circle because the square div blocks interaction with the background. I want to ensure that the circular div in the middle remain ...

The appearance of the page varies when viewed on different computers using the same version of Firefox

Previously, I posed a question with a touch of irony regarding Firefox without providing an example. As a result, my question was downvoted and I had to request its removal. Now, I have an example illustrating the issue at hand. It took some time to clean ...

It's possible for anyone to enhance the appearance of the Download button by adding styles without compromising its functionality

Looking to enhance the style of the Download button as it appears too formal. Seeking assistance in adding some button styles to make it more stylish. The code is correct, just aiming to give the Download button a trendy look with specified styles. ...

"Ascend beyond the constraints of fixed measurements with dynamic

My JQuery image fader has a width of 100% and height set to auto. I'm thrilled that it works perfectly on the iPhone as well. Now, I am facing a challenge while trying to make content "float" after my JQuery slider. The problem arises because I use ...

How to Override Global CSS in a Freshly Created Angular Component

My CSS skills are a bit rusty and I need some assistance with a project I'm working on. The project includes multiple global CSS files that have properties defined for different tags, such as .btn. However, these global CSS files are causing conflicts ...

Tips for changing the dimensions of the canvas?

I'm struggling to display a photo captured from the webcam. The sizes are not matching up, and I can't pinpoint where the size is defined in the code. https://i.stack.imgur.com/Is921.png The camera view is on the left, while the photo should be ...

How can you quickly navigate to the top of the page before clicking on a link in the same window/tab?

Could someone assist me with a coding issue I am facing? I would like to be able to go to the top of the page when clicking on a link and have the link open in the same tab. I attempted to implement this functionality using the following code, however, I ...

Utilize CSS to style Hover effects

Can someone please assist me with this issue? I am having trouble getting the CSS to work for my hover effect. I suspect that there might be a problem with my syntax. Here is the HTML code: <div id="horizontalmenu"> <ul> <li><a h ...

Easy fix for 3 circles (images) placed in a row with equal distance between them and perfectly aligned

I've been spending the last 3 days trying to accomplish this specific task: 3 circular images arranged horizontally with equal spacing Occupying 70% of the central screen area Height and width based on percentages for browser resizing adjustment It ...

Using jQuery Datatables with Asp.Net

Having encountered an issue with displaying two jQuery datatables in separate menu tabs, I am seeking assistance to rectify the problem. The first datatable (id=gvSchedule) appends successfully while the second one (id=gvMySchedule) loses its formatting up ...

Is it possible to switch the placement of my sidebar and content?

For some reason unbeknownst to me, I have created two distinct CSS classes called content and sidebar1. My original intention was to position the sidebar on the right side of the page. However, no matter what adjustments I make, the sidebar stubbornly rema ...