Fixed-positioned elements

I'm facing a small issue with HTML5 that I can't seem to figure out.

Currently, I have a header image followed by a menu div containing a nav element directly below it. My goal is to make the menu div stay fixed when scrolling down while keeping the rest of the page scrollable.

I've tried various CSS and JavaScript solutions to achieve this but haven't been successful. Can anyone help me with this problem?

//Edit1: I attempted using CSS for the header but my main focus is on making the menu overlay the header without interfering with it. I found an example that demonstrates this, but I'm having difficulty editing the code successfully:

Example Link

JSFiddle Link

<body bgcolor="#FFFFFF">
<div class="wrapper">
    <header>
        <img src="../doc/img/cabecera.png" width="1024" height="170" alt="" />
    </header>http://jsfiddle.net/kesarkes/uJsHL/embedded/result/
    <!--<div class="fijado">-->
    <div class="menu">
        <nav align="center">
            <ul>
                <li id="home1"><a href="index.html">Home</a>
                </li>
                <li id="folio2"><a href="#b1">Folio</a>
                </li>
                <li id="bio3"><a href="#bioinfo">Bio</a>
                </li>
                <li><a href="contact.html" target="_blank">Contact</a>
                </li>
            </ul>
        </nav>
    </div>
    <div class="slideshow"></div>
    <div class="fotos">
        <hr id="b1"></hr>
        <div class="grupo_foto"><a href="1"><div class="grupo_foto1_1"></div></a>
        </div>
       <!-- more code goes here -->
</div>

Answer №1

Make sure to include the z-index property in your code so that the content doesn't overlap the header.

header {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
}

View the updated demo on the fiddle.

Demo

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

Discovering the process of mapping transitions in MUI

I'm struggling with mapping my products in mui and placing each one in Grow. However, I keep getting this error message: "Warning: Failed prop type: Invalid prop children of type array supplied to ForwardRef(Grow), expect a single ReactElement". Can a ...

Starting Web Server using File (file://) protocol

I'm currently using Quasar to develop a Vue SPA web app/page. For this project, the web app will only run by clicking on the index.html file generated by the Quasar packager. This package will not be distributed online or hosted on any domain. My mai ...

How does a JSONP request differ from an AJAX request?

I have searched extensively for a solution to the matter mentioned, yet I did not come across anything intriguing. Would you be able to clarify it in simple terms? ...

What steps should I take to identify and handle an error in an Ajax query post?

I want to handle errors and display the corresponding message when an Ajax request fails. Here is my code, but I am struggling to catch the failing Ajax requests. function getAjaxData(id) { $.post("status.ajax.php", {deviceId : id}, function(data){ ...

Iterate through the xml.documentElement in a loop

I want to show 8 men and 2 women in SVG format. However, my current function only displays one man and woman. How can I add a loop to make this work for all individuals? for (i = 0; i < Serie[n].Number; i++) { return xml.documentElement } The data arr ...

Tips on positioning the down arrow of an accordion-button to the left

I need to adjust the placement of the down arrow on an accordion button for my Arabic language website. Here is the current code snippet: <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-c ...

Mastering the Art of Implementing Jquery Contains Function

Exploring the jQuery website led me to the contains selector. $("div:contains('John')").css("text-decoration", "underline"); I am trying to figure out how to make this work with a dynamic value instead of hard-coding it. I attempted something l ...

Automatically updating div content using a static HTML page

Is there a way to refresh the content of an HTML div tag every 5 minutes without having to reload the entire page? <div id="pie"> <script src="index.js">// this script should be reloaded every 5 minutes </script& ...

The conflict between Material UI's CSSBaseline and react-mentions is causing issues

Wondering why the CSSBaseline of Material UI is causing issues with the background color alignment of React-mentions and seeking a solution (https://www.npmjs.com/package/react-mentions) Check out this setup: https://codesandbox.io/s/frosty-wildflower-21w ...

What is the best way to update or change a value in a JSON file?

This specific file is structured in JSON format shown below: { "ClusterName": { "Description": "Name of the dbX Cluster", "Type": "String", "MinLength": "1", "MaxLength": "64", "AllowedPattern": "[-_ a-zA-Z0-9]* ...

Steps for creating a fade effect between two different elements when the mouse is interacting with one of them

I want to create a unique effect with an image in the background and a button above it. When the mouse hovers over the button, I want its opacity to decrease while the image's opacity increases simultaneously. I have experience applying fade effects ...

How does Backbone.js tackle error handling when receiving messages from Rails?

Can anyone using backbone.js lend a hand? How can error messages from a rails app be encoded when integrating with backbone.js? For instance, how should flash messages like "record not found" be handled? While errors are usually defined on the client sid ...

What is the best approach for extracting JSON data (using jQuery) from Google Geocoding services?

Obtaining the city name using latitude and longitude is my current challenge. Google Geocoding offers a helpful solution known as "Reverse geocoding". According to the documentation, a GET request needs to be made to the following link: http://maps.googl ...

Is there a way to transform an angular 2 app.module into ES6 format?

import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; //specific imports remov ...

Content that can be scrolled within a React.Box container

I am struggling with a particular view. The columnBox I have can potentially hold a large number of items, but for some reason it's not scrolling in the view. I've already tried setting overflowY to auto, but since I don't know the exact hei ...

Error: JSON encountered circular structure when attempting to serialize an object of type 'ClientRequest' with a property 'socket' that references an object of type 'Socket'

Encountering an error while attempting to make a POST request to my TypeORM API using axios: TypeError: Converting circular structure to JSON --> starting at object with constructor 'ClientRequest' | property 'socket' -&g ...

Ways to specifically target the scrollbar of a scrollable div without affecting its `li` descendants or grandchildren

How can I use jQuery's :not(x) selector? For example, can I exclude a specific HTML element like :not("li")? I've seen the official jQuery documentation mentioning :not(#id) and :not(.class), but what about excluding markup elements l ...

Using Express.js to leverage Vega for generating backend plots

Exploring ways to create plots using backend code and transfer them to the front end for display. Could it be feasible to generate plots on the server-side and then transmit them to the front end? I am interested in implementing something similar to this: ...

I am interested in checking the dates of the current date and disabling the button if the date falls within that range

I am attempting to deactivate a button if the current date falls within a three-month period. Despite my efforts to use a combination of Php and JavaScript, I was unable to make it work. PHP Code @php($found = false) @foreach($doctors as $doctor) ...

React router updates the URL without affecting the actual display

I am facing an issue in my React project where the URL changes when clicking a link, but the view does not update. I have a separate route and links file, and I can't seem to figure out the problem. Here is my index.js: import React from 'react ...