Having trouble with the float not working for the main content below the sidebar? Stay tuned

Here is the layout I am working with:

.page-wrapper {
  height: 100%;
  min-height: 970px;
  position: relative;
}

.pageheader {
  min-height: 50px;
  position: fixed;
  min-width: 100%;
}

.navbar-fixed-top {
  top: 0;
}

.page-sidebar {
  float: left;
  width: 180px;
  top: 0;
  overflow: auto;
}

.page-content {
  min-height: 970px;
  float: left;
}

footer {
  width: 100%;
  text-align: center;
  position: relative;
}
<div class="page-wrapper">
  <div>
    <div id="header" class="pageheader navbar navbar-fixed-top">
      Navbar Top
    </div>
    <div class="clearfix"></div>
  </div>
  <div class="content-wrapper">
    <div>
      <div class="clearfix"></div>
      <div id=".navbar-collapse" class="page-sidebar">
        Navbar Side
      </div>
      <div class="clearfix"></div>
    </div>
    <div>
      <div id="content" class="page-content">
        Content
      </div>
    </div>
    <div>
      <footer id="footer">
        Foter
      </footer>
    </div>
  </div>

The issue I am facing is that my main content-wrapper is appearing below the sidebar and footer, somewhere in the middle of the page. I have attempted using

display:inline-flex

on content-wrapper to place page-content next to sidebar, but the footer still remains in the middle of the page. Any suggestions on how I can resolve this would be greatly appreciated.

Answer №1

To adjust the width of the page-content, you can utilize the calc function. See the revised code snippet below

body {
    margin: 0px;
}
.page-wrapper {
    height: 100%;
    min-height: 970px;
    position: relative;
    width: 100%;
    padding-top: 50px;
    display: block;
}    
.pageheader {
    min-height: 50px;
    position: fixed;
    min-width: 100%;
    background: red;
}
.navbar-fixed-top {
    top: 0;
}
.content-wrapper {
    background: grey;
    float: left;
    width: 100%;
}
.page-sidebar {
    float: left;
    width: 180px;
    overflow: auto;
}
.page-content {
    min-height: 970px;
    float: left;
    background: green;
    width: calc(100% - 180px);
}
footer {
    width: 100%;
    text-align: center;
    position: relative;
    background: black;
    clear: both;
}
<div class="page-wrapper">
    <div>
        <div id="header" class="pageheader navbar navbar-fixed-top"> header <br/>
        </div>
        <div class="clearfix"></div>
    </div>
    <div class="content-wrapper">
        <div>   
            <div class="clearfix"></div>
            <div id=".navbar-collapse" class="page-sidebar"> sidebar </div>
            <div class="clearfix"></div>
        </div>
        <div>
            <div id="content" class="page-content"> content </div>
        </div> 
        <div class="clearfix"></div> 
        <div>
            <footer id="footer"> footer </footer> 
        </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

Sending information from a dynamic table to a database using PHP

I've created an HTML webpage with a table that fetches data from my database. Each row in the table has a button that, when clicked, dynamically adds the data into another table on the webpage using JavaScript. The dynamic table includes a submit butt ...

What is the best way to define relative paths for content like CSS files?

Whenever I link to a file, I always find myself having to include the entire absolute path like this <link rel="stylesheet" type="text/css" href="F:/XmppOld/XAMPP2/htdocs/MAIN_SITE_LAYOUT/css/stylemainpage.css" /> I want to simplify it to ...

Steps to display a video using a Jupyter widget in a Jupyter Notebook

Imagine I have a directory containing 4 video files (such as "movie1.mp4", "movie2.mp4" and so on). I aim to utilize ipywidgets to enable the user to choose which video they want to watch. Here's an example: import ipywidgets as wd from IPython.disp ...

AngularJS: Utilizing $http to fetch XML data instead of JSON

Looking to extract data from a website using angularjs / javascript. I am familiar with the $http object in angularjs which can make get requests. I have used it before to retrieve json, but I'm wondering if I can use it for XML (HTML) as well? (I th ...

What is the best way to ensure that the columns are the same height, regardless of the varying content they contain

Visit my CodePen For this particular layout, I need to use only CSS. The columns are structured like so: <div class="col-md-12 no-border no-padding"> <h2 class="heading upper align-center">Headline</h2> <p class="subheading lower ...

How can I make an inline h1 with a span that is aligned to the end?

I am attempting to create the most basic react app possible and I want to design a header using Bootstrap 4. The header will have two parts: the first part on the left side and the second part on the right side. Currently, my code looks like this: <di ...

Include a scrollbar within a div element nested inside a table cell

index.html <div id="wrapper"> words go here, many of them </div> style.css #wrapper { height: 100%; width: 200px; overflow: auto; } I have been struggling to display the scroll bar on my page, and this is what I am currently exp ...

Parsing of CSS and Javascript is disabled within iframes

Within my node.js application, I have configured an endpoint where I can load some parsed HTML code. This is achieved through the following code: app.get('/code', function (req, res) { res.setHeader('Content-Type', 'text/html& ...

Create a dynamic and interactive website using a combination of jQuery and AngularJS

I recently came across an interesting tidbit on the FAQs of Angular stating that "Angular can use jQuery if it's present in your app when the application is being bootstrapped". This got me thinking, is it considered a best practice to include both j ...

Aligning buttons in an inline form with Bootstrap

Issue with Button Alignment Post Validation. <form class="form-inline form-padding"> <div class="form-group"> <div class="input-group"> <input class="form-control" placeholder="First Name" name="fir ...

Tips on choosing JSON data to show on an HTML page

I am working with JSON data from a specific URL and I need to display only the information related to France on an HTML page. However, I am unsure of how to achieve this. Can someone please assist me? Here is my JavaScript code: // API Fetch Call const ...

Transforming jQuery object into HTML code

I need assistance with a JavaScript task where I am trying to parse and replace an item within an HTML string, but then struggling to convert it back to a string. Specifically, I am having difficulty turning the new jQuery object back to HTML. var compile ...

Learn the process of updating Datatables' multiple column headers in real-time using ajax and jquery, all without the need to refresh

My goal is to dynamically change the column number and header of a table based on the return value of an AJAX call in conjunction with DataTables jQuery plugin. Below is the JavaScript and jQuery code I am currently using: $( document ).ready(function() { ...

CSS hover image resizing not functioning as expected

Is there a way to dynamically scale up an image when hovered over? I'm trying to achieve an effect where the image increases from 100x75 pixels to 300x225 pixels. Everything seems to be working fine with the layout, but the width doesn't seem to ...

Do you know of a more streamlined approach to formatting this SCSS code?

Currently working on a Saleor Site and diving into the world of Django and SASS for the first time. While crafting my own styling rules in SCSS files, I've noticed some repetitive code that could potentially be streamlined. It seems like there should ...

Positioning of header, main content, and footer elements

My webpage is structured into three sections: the header, the main, and the footer. The header at the top has a fixed height of 109px with a 6px border. The main section should extend across the entire page below the header and reach the bottom where the ...

Enhance user experience with jQuery UI sortable and the ability to edit content in real

I am facing an issue with jquery sortable and contenteditable. The problem arises when I try to use jquery sortable along with contenteditable, as the contenteditable feature stops working. After searching on Stack Overflow, I found a solution. However, up ...

What is the reason behind my button appearing beneath my links in React?

https://i.sstatic.net/Qmm4z.jpg Here is an image showcasing the current header render. The header consists of a HeaderMenu and 3 Links. While the links are functioning properly, the HeaderMenu is causing the links to be positioned below it. The HeaderMenu ...

Implement transition effect on collapsible div with styled-components in React

I am attempting to develop a straightforward collapsible div using styled-components within a react project. While I have successfully managed to toggle the div's open and close state based on certain conditions, I am facing difficulties in implement ...

Bootstrap doesn't display in the dropdown menu

Struggling to get a dropdown menu to display on my page, my HTML code is: <div class="dropdown d-inline"> <div class="widget-header mr-3"> <button href="#" class="icon icon-sm rounded-circle border" data-toggle="dropdown"><i cl ...