Div with a fixed position that is displayed on top of another following div

Having trouble with my code on this fiddle: https://jsfiddle.net/0vau6psp/. It seems to be related to the position:fixed property, but I can't seem to solve it.

The issue is that the header is overlapping the main content, making it invisible. I want the content to appear below the header instead.

If anyone could provide some guidance, it would be greatly appreciated! Here's a snippet of my code for reference:

HTML:

<header class="site-header" >
  <div class="header-main" id="header-flow">
    <div class="container-fluid header-cont-top-nav">
      <div class="row">
        <div class="col-md-5 text-right hidden-xs hidden-sm">
            <ul>
            <li>Link</li>
            <li>Link</li>
            <li>Link</li>
            </ul>
        </div>
      </div>
    </div><!--/.container-->
  </div><!--/.header-main-->
</header>
  <main class="site-main-content" id="mainscrollcontent">
      <p>
       {{ content_for_layout }}
       Test
       Test Content
       Test Content line 4
       </p>
  </main>

CSS:

#header-flow {
    border-bottom: #73b2b2 3px solid;
    z-index: 1000;
    background-color: #fff;
    position: fixed;
    width: 100%;
}
#header-flow li{
display:inline-block;
}
.site-main-content {
    margin-bottom: 0;
    display:block;
}

Answer №1

To avoid using margin-top:, padding:, or applying style to the subsequent HTML elements below your fixed header, you can insert an empty div for this purpose.

.block { 
    height: 120px; // customize
    width: 100%;
}

Demo. & Sample.

Answer №2

To lower the .site-main-content section, consider incorporating padding-top or margin-top into its CSS.

Answer №3

In the HTML code, you first set the header's position and then the main section beneath it.

Here are your options:

  1. Remove the line that fixes the position of the header.
  2. Change the order
  3. Add position:relative;

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

Blending HTML template and WordPress PHP file

I am facing a challenge while attempting to implement a Wordpress template on one of the pages of my website, specifically at http://www.windowblindshadeshutters.com/blog/. The blog has been successfully created, however, I am having trouble preserving our ...

showcasing a map on an HTML webpage

Seeking advice on integrating a map feature in HTML to mark store locations. Working on an app for a business community and need help with this specific functionality. Your assistance would be greatly appreciated! ...

Discovering instances of a specific string within a larger string

My goal is to customize the default behavior of the alert function. Below is the code I am using: window.alert=function(txt) { waitOk='wait'; setMsgBox(txt); btnMsgOk.focus(); } However, I need this functionality to vary ba ...

How to align multiple span elements vertically using HTML and CSS

<div class="row history"> <div class="col col-50 histroy1"> <span class="my-orders">Statistics</span> <span class="my-orders-numbers">27</span> </div> <div class="col col-50 histroy ...

Is there a distinction between "muted" and "volume = 0.0"? Event listeners handle them in separate ways

I am a newcomer to coding and have encountered an issue that has me stumped. I am working on developing a small media player intended for use with the athletes I coach. The concept is to require them to listen to my commentary while watching game footage. ...

CSS class is functioning properly in conjunction with the textarea element, but it is not properly

I have a CSS class called ".form_bg_color" with the following definition: .form_bg_color{ background: red; } When I apply this class to my text field in the view like so: <%= f.text_field :source, class: "form_bg_color" %> The color of the input ...

sending live video from a Python server to a browser-based client

Is there a way to stream a video from a python server to an HTML page web client (Node.js)? In my Node.js web project, I am currently using Python to write frames and JavaScript to read them. However, I am facing limitations with both frame rate and resol ...

Insert a new row into a table using tablesorter jQuery

Is it possible to add a row to a table built with the jQuery library "Tablesorter" by simply clicking on a button? I have tried this approach, but unfortunately, the new row does not inherit the CSS properties of Tablesorter. As a result, I am unable to se ...

Paste the URL into your clipboard without relying on JavaScript

Is there a way to implement a copy to clipboard function for email templates without relying on JavaScript? ...

Examining the functionality of my PHP codes and forms

I'm currently working with two HTML forms and two PHP scripts. The first form is designed to save a user's email to a .txt file, while the second form is a Stripe payment form that processes payments using PHP code. However, I've encountere ...

Do I have to implement a column grid for creating responsive websites?

I'm feeling a bit uncertain about the necessity of a column grid for creating a responsive website. For instance, I plan to kick off with the Bones WordPress theme. My intention is to utilize the SCSS setup provided in this theme. The grid it offers i ...

CSS: The grid-column and grid-row properties are malfunctioning

I'd like to create a grid with one column containing multiple rows of text, and the second column having an equal number of input rows. My initial plan was to create a grid where the number of rows equals the number of lines of text, and then define t ...

Dynamically insert ID into a div element

Hi there, I have an ID "network" in the div class "parent". Inside this parent div, there is a for loop that generates multiple IPs. Whenever I click on a specific parent IP, it should call its child div. How can I dynamically generate IDs so that I can pl ...

Data is not displaying correctly in the Angular Material Table

I'm currently trying to build a mat table based on an online tutorial, but I'm facing a problem where the table appears empty even though I have hard coded data. As someone new to Angular and HTML/CSS, I'm struggling to understand why the ma ...

Is it possible to alter the name of a slot before displaying the element in the shadowDOM, depending on the slot utilized in the DOM?

In my project, I am working on implementing different features for both desktop and mobile devices. Some of these features can be replaced by slots. My goal is to have a slot that can be either replaced by a desktop slot called poster-foreground, or a mobi ...

Resolving problems with image dimensions in Angularjs and ionic framework

I'm attempting to achieve a design where the first image occupies 50% of the screen's height and 100% of its width, while the second image does the same. Please refer to the image below: https://i.sstatic.net/nwmRP.jpg ...

What is the best way to change the active class using jquery?

Excuse me, can I get some help? I'm still learning html and jquery, and I've seen this question asked before, but none of the solutions seem to work for me. I'm trying to change the active class in my navbar when I click on another link. Wh ...

What is preventing me from retrieving an ID value within an IF condition?

I'm trying to create a script that only allows devices with matching IP addresses, but I'm having trouble using an if statement. Whenever I include x.id inside the statement, it doesn't seem to work... any suggestions? <html> <sc ...

JavaScript Bug Report

Currently, I am immersed in a project that encompasses various languages like HTML, JS, and PHP. While working on one of the PHP functions, I stumbled upon an unexpected anomaly. To dissect it better, I decided to break it down into simpler functions: &l ...

Angular - when removing items from ngRepeat, the remaining elements do not transition smoothly; instead, they abruptly snap or jump into position

Currently using AngularJS v1.4.8 with ngAnimate injected into my controller. In the process of creating a dynamic list using ngRepeat, tied to an array. The addition and updating of items in the list function smoothly with animations working as intended. ...