Steps for building a dynamic layout using bootstrap 4

I've been working on creating a responsive layout similar to the image using Bootstrap 4, but I'm encountering some issues. Specifically, I'm having trouble making the sidebar and bottom bar fixed, as well as adjusting the size of the bottom bar. Additionally, I need both the main content and sidebar to have individual overflow scrolling.

  1. fixed top nav bar >done
  2. fixed side bar
  3. fixed bottom bar > done
  4. bottom bar size should be same as main body

Expected output https://i.sstatic.net/DCvob.png

Here is my progress so far:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

  <title>Document</title>
</head>
<style>
  html,
  body {
    height: 100%;
  }
</style>

<body>
  <!-- Top Nav Bar -->
  <nav class="navbar  navbar-expand-lg navbar-dark bg-dark fixed-top">
    <a class="navbar-brand" href="#">logo</a>
    
    

    
  </nav>

  <!-- Main Body -->
  <div class="container-fluid h-100" >
    <div class="row h-100">

      <!-- Left Body -->
      <div class="col-sm-10" style="background-color: #F0F2F5;">
        <div class="container-fluid" style="margin-top:80px">
            <h1>some text</h1>
            <h1>some more text</h1>
            
        </div>
      </div>

      <!-- Side Nav Bar -->
      <div class="col-sm-2 border" style="margin-top:55px;" >
        <h5>list</h5>
        <hr>
        <h1>some text</h1>
        
      </div>

    </div>
  </div>

  <!-- Bottom Player -->
  <nav class="navbar fixed-bottom navbar-dark bg-dark" >
    <div class="container" style="width: 50%;height: 40px;">


    </div>
  </nav>


</body>

</html>

Answer №1

Could you kindly review the code provided below? We have made some adjustments to enhance its functionality. The inline styling has been removed from all elements. Specifically, we added a style to the sidebar element .sidebar-content by setting it as position: fixed; and adjusting its position according to your requirements. Additionally, we applied a style to the .content-main element, making it scrollable content with padding customized to suit your needs. We also set the width of the .footer (bottom bar) to match that of the .content-main (main body).

Please refer to this link for more details: https://jsfiddle.net/yudizsolutions/14ybmh92/7/

body {
    background-color: #F0F2F5;
  }
  main { 
    padding: 56px 0;
  }
  nav.header{ 
      z-index: 1060;
  }
.row .sidebar-content{
    
    position: fixed;
    right:0;
    bottom:0;  
    overflow: auto;
    overflow-x: hidden;
    height: calc(100% - 56px);
    z-index: 1050;
    background-color: #fff;
}
.content-main{
   
    height:calc(100vh - 112px);
    overflow-y: scroll;
}
.footer{ 
    max-width: calc(100% - 16.666667%);
}

@media (max-width:767px)

/* for mobile */
  {
  .sidebar-content {
    position: unset;
    height: 100%;
    z-index: 100;
    background-color: #fff;
  }


}
<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

    <title>Document</title>
  </head>
  <style>
    html,
    body {
      height: 100%;
    }

  </style>

  <body>
    <!-- Top Nav Bar -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
      <a class="navbar-brand" href="#">logo</a>
    </nav>
    <main>
      <!-- main body-->
      <div class="container-fluid h-100">
        <div class="row h-100">

          <!-- left body-->
          <div class="col-sm-10 content-main">
            <div class="container-fluid">
              <h1>some text</h1>
              ...
            </div>
          </div>

           <!-- side nav bar-->
          <div class="col-sm-2 border sidebar-content" style="margin-top:55px;">
            <h5>list</h5>
            <hr>
            <h1>some text</h1>
             ...
          </div>

        </div>
      </div>
    </main>

    <!-- bottom player-->
    <nav class="navbar fixed-bottom navbar-dark bg-dark">
      <div class="container" style="width: 50%;height: 40px"></div>
    </nav>


  </body>

</html>

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

Aligning the email form to the center with the text-align center property:

I'm in the process of creating an app landing page using the Bootstrap framework (Bootstrap 4 alpha). I have used text-align:center in the jumbotron id to center everything, but the email form is not aligning properly. Is there a way to center align ...

Dynamically create a button using jQuery and JSON based on specific conditions (either true or false)

Is there a way to generate buttons with specified parameters only if a condition is true? Currently, the buttons are generated without checking conditions. Any help with the correct syntax would be appreciated. Sample JSON code: { "Caption": "Module ...

Issues arise when attempting to insert data into an HTML file using PHP

Good evening, I am having a problem where when I attempt to use PHP to replace "hello world" in an HTML file, it ends up completely empty each time. Can anyone point out what mistake I might be making? Here are the HTML and PHP files: <!DOCTYPE html&g ...

What is the best way to ensure a table is responsive while maintaining a fixed header? This would involve the table scrolling when it reaches the maximum viewpoint, while also keeping

Can anyone help me create a responsive table with a fixed header that scrolls when it reaches the maximum viewpoint without scrolling the entire page? I've tried using box-sizing: border-box; and overflow-x:scroll; but it didn't work. Any suggest ...

Enhance the color scheme of your collapsed or expanded Bootstrap NAV for mobile devices

Currently working on customizing the navbar using Bootstrap. I've been able to style it perfectly for both desktop and mobile devices in its initial state. The issue arises when attempting to style the navbar in its expanded and collapsed states on m ...

Personalize the breakpoints of Bootstrap 4's grid system

In my project, I am facing a situation where I need a 1280 breakpoint to switch from desktop to tablet, instead of the xl breakpoint at 1200 as defined in Bootstrap. How can I globally change the xl breakpoint in Bootstrap without recompiling from the sour ...

What is the best way to navigate to a specific element using jQuery?

I am having an issue with scrolling to a specific div at the top of my page. Even though I have buttons for other sections, when I scroll to the bottom and click on the button, it does not take me to the top of the page as intended. You can view the CodeP ...

Which is better for parsing HTML - CSS or XPath selectors?

For my project, I aim to utilize lxml for parsing HTML content, as it offers support for both XPath and CSS selectors. I am currently deciding whether to bind my model properties to either CSS or XPath. I am contemplating which option would be most benefi ...

What is the best way to align these Iframes in the center?

This is the html <div class="main_content"> <section class="episodio"> <article class="contenedor_episodios"> <h2>Episodios</h2> <div class="episodio_spotify" ...

Associating data with controller upon click event

My application displays a tab full of objects for the user to choose from by clicking on any line. Once they make their selection, I need to send specific data related to that object to the server. This is what the interface looks like: https://i.sstatic ...

How can I write a click event for an image within a PNG using jQuery?

Is it possible to add a click event to an image with a hole inside, allowing the image behind it to show through? Check out this JSFIDDLE for reference //javascript code $('#ant').click(function() { alert("hi"); }); ...

Instructions for connecting a button and an input field

How can I connect a button to an input field? My goal is to make it so that when the button is clicked, the content of the text field is added to an array (displayed below) const userTags = []; function addTags(event) { userTags.push(event.target.__ wha ...

Set the height of CSS3 to 100% full

I'm struggling to articulate my question, so please feel free to suggest a better title or guide me in the right direction. I'm working on a website using a mix of HTML5 and CSS3, and I want it to display consistently across various browsers. H ...

Building a floating video player using React

I recently installed the React-Player module and it is functioning perfectly. However, I am encountering some difficulties in trying to embed the player within an Element so that it appears as a floating player across my application, regardless of the page ...

Flexbox mystery: How come the entire div isn't displayed when the element below it is hidden?

I am in need of a versatile column layout where multiple widgets are stacked vertically, adjusting their size dynamically. Each widget consists of a title and scrollable content. The last widget should have the ability to collapse when its title is clicked ...

Basic event listener function, functional in CodePen but not operating in Chrome web browser

I'm experiencing an issue where event listener functions are not working on my browser (Chrome), but they work fine on CodePen. I've been troubleshooting this for about 2 hours, and I'm seeking some insights. Can anyone help? CodePen Link: ...

Unable to adjust layout when code is functioning alongside background-color

I'm looking to dynamically change the position of an item on my webpage when it is clicked. Is there a way I can achieve this without relying on id names? I currently have a code snippet that successfully changes the background color, but for some rea ...

Is the default animation duration of Compass being ignored?

After recently updating to Compass version 1.0.16, I started setting up basic usage of the new animation features. However, I encountered an issue where setting default values for different animation settings did not take effect. This led me to hard-code t ...

Place the cursor at the conclusion of the text box

I am working on creating a user input form for chat messaging and I need some help. Here is the HTML-code snippet that I am currently using: HTML-code Currently, when the user presses ENTER, I retrieve the text from the textbox and save it. If the user ...

Arrange list items dynamically using ajax

I am attempting to adjust the positioning of the scrollable list item depending on whether a message was sent by a user or another party. However, my current method is not yielding the desired results. I have experimented with adding .css('position&a ...