In order to address the positioning of the container-fluid between the fixed-top and fixed-bottom elements

Currently utilizing Bootstrap 4 for a responsive template. The header and footer have been successfully fixed using the fixed-top and fixed-bottom classes.

However, the next goal is to fix the container class between the header and footer. This way, the content can remain fixed or scroll within that container without affecting the positioning of the header and footer.

Any suggestions or assistance would be greatly appreciated. Thank you!

Answer №1

To easily manage header and footer height, use margins:

header {
  background: red;
  height: 100px;
}

footer {
  background: green;
  height: 70px;
}

.container {
  background: white;
  margin-bottom: 70px;
  margin-top: 100px;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">

</head>

<body>
  <header class="fixed-top">HEADER</header>
  <div class="container">FIRST CONTENT ...LAST </div>
  <footer class="fixed-bottom">FOOTER</footer>
</body>

</html>

Answer №2

If you want the middle container to stay fixed at the top, make sure to add enough margins so it doesn't overlap with the header and footer.

.container-fixed {
background: yellow;
margin: 40px 0;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
Header
</nav>
<nav class="fixed-top container-fixed">
Content
</nav>
<nav class="navbar navbar-expand-md navbar-dark fixed-bottom bg-dark">
Footer
</nav>

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 best way to search for a CSS selector that includes an attribute beginning with the symbol '@'?

Whenever I want to target an element with a click event, I usually use the following jQuery selector: $('div[@click="login()"]') <div @click="login()"> Login </div> However, when I tried this approach, it resulted ...

Modifying color in CSS for an SVG that is dynamically animated using JSON

I recently obtained an animated hamburger menu icon for free from this particular website. The animation triggers on click and reverses on the second click, functioning smoothly. Now, I am seeking guidance on changing its color using CSS. // JSON var ...

Changing the position of the checkbox label to be above the checkbox

Can you help me with rearranging the checkbox label position to be above the checkbox instead of on the left side? I currently have the labels appearing on the left-hand side of the checkboxes, but I would like them to be positioned above the checkboxes. ...

Getting all "li" elements from the "ul" class using Selenium WebDriver is a required task for web scraping or automated testing

As a beginner in Selenium webdriver, I recently encountered a task where I need to automate clicking on all links within a specific section. Could someone provide me with the Java code for this? I have attached an image displaying the Firebug properties of ...

Edge and Internet Explorer fail to recognize the :focus CSS selector

I am utilizing CSS to make our placeholders jump up when clicked inside, but Edge is not recognizing the CSS. It works fine on every other browser except for Edge. I've tried various solutions but none seem to work on Edge. Any thoughts on what might ...

Activate a CSS class on click using JavaScript

Having a bit of trouble as a beginner with this. Any help would be much appreciated. This is the code in question: HTML: <div class='zone11'> <div class='book11'> <div class='cover11'></d ...

What type of modelfield in django can store the duration of a video playback? Alternatively, how can a TimeField be used without an

It's surprising that I haven't found a solution on SO yet, but my current challenge involves storing information when a user taps/clicks on my video player. I am currently saving the current playback time in a TimeField as shown below: class Ta ...

Guide to displaying or concealing the header using PHP

Once the add button is clicked, the text should be hidden and the form should be displayed. Check out my code below: <h2 style="font-size: 2em; margin-bottom: 0.75em; margin-left: -1%;">Specify Co-Owners for self occupied property</h2> <div ...

Retrieve information from an HTML form, make updates to the database, and exhibit the data in a table on the current page with the help

I'm in need of some assistance. I have a small application that utilizes a Java Servlet and an HTML form. The user enters data into the HTML form, and upon clicking the submit button, the Java servlet retrieves this data in its post method and stores ...

The elements within the HTML, CSS, and Bootstrap are all clashing and

Website Output https://i.sstatic.net/5JVyg.jpg I've been working on a small website with a bootstrap carousel, and in this specific section of the program, the Bootstrap and HTML/CSS elements overlap by default. I'm not sure how to separate the ...

My CSS seems to be causing an issue and preventing the function from running correctly. Now I just need to

I'm currently working on a project and following a tutorial to help me create a navigation bar. The tutorial I am using can be found here: https://www.youtube.com/watch?v=gXkqy0b4M5g. So far, I have only reached the 22:05 mark in the video. I have su ...

Using Beautiful Soup to scrape the web and populate a Python list with the data

I have been working on learning how to web scrape with Python and BeautifulSoup, but I am running into an issue. When I try to add scraped items to a new list, only the final entry in the relevant tags is being displayed when I print the lists. How can I m ...

Can you tell me which specific font Adobe Edge Code (Brackets) uses in its code editor?

Can someone please help me? I'm trying to identify the syntax highlighter being used in this code. Is it Prettify or something else? ...

Is it necessary to adjust my font stack for optimal viewing on a high DPI tablet or computer screen?

My CSS includes the following font definition: html { font-size: 95%; font-family: Arial, Helvetica, sans-serif } I want my application to display well on PC, iOS, and Android tablets. I am aware that different devices have varying resolutions. C ...

Mobile phone web development using HTML5

I am currently facing an issue with playing sound on mobile browsers. In my code snippet, I have the following: Response.Write("<embed height='0' width='0' src='Ses.wav' />"); While this works perfectly fine on desktop ...

Is it possible to target elements based on a specific CSS3 property they use?

Is there a method to target all elements in the DOM with a border-radius other than 0? If anyone has suggestions, it would be greatly appreciated! ...

Is there a way to automatically scroll 50 pixels down the page after pressing a button?

Is there a way to make my page scroll down in Angular when a button is clicked? I attempted to use this code, but it didn't have the desired effect. What is the best method for scrolling the page down by 50px? window.scrollBy(0, 50); ...

Preventing an object from exceeding the boundaries of its designated space

My DIV is filled with user-generated content, which sometimes begins with an item that has a margin-top that overflows the container, creating a gap between it and preceding elements. I've discovered that changing the display property to either inline ...

Style sheets for two dynamically-sized boxes side by side

There are two boxes or columns positioned on the same line. Both have varying widths that need to remain on the same row. To clarify: .----------container 570px-----------. |[box1] [box2]| Ideal scenario | ...

Is it possible to execute a function defined within an eval() function using setInterval()?

const evaluation = eval(document.getElementById("codearea").value); setInterval(evaluation, 10); I am seeking a way to access a function that is declared within the eval function, for example: setInterval(evaluation.examplefunc, 10) I attempted ...