Web page glitch repaired: Top fixed div now functioning properly

I am currently facing an issue with a fixed header and full-screen background image. The problem arises when I try to display an alert on top of the page, pushing down the header and hero section. However, I am encountering difficulties as the alert either does not appear at all or if it does, it fails to remain fixed and scrolls with the page.

.sitrep {
    top: 0;  
    height: 50px;
    width: 100%;
    position: fixed;
    z-index: 10000; 
}



.siteHeader {
    min-height: 76px;
    height: 76px;
    overflow: visible;
    background-color: #000;
    color: #f4f4f4;
    position: fixed;
    top: 0;
    z-index: 10000;
}





#hero {
    height: 100vh;
}

.hero {
    background: url(images/hero-bg.jpg) no-repeat top center;
    background-color: #000;
    background-size: cover;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
}

#hero-content {
    position: absolute;
    width: 100%;
    bottom: 0%;
}

#hero-content a {
    background-color: #131313;
    padding-top: 10px;
    height: 40px;
    display: block;
    font-size: 12px;
    text-align: center;
    text-transform: uppercase;
    text-decoration: none;
}

#hero-content img {
    display: block;
    margin-top: 2px;
    max-height: 145px;
    margin-right: auto;
    margin-left: auto;
    margin-bottom: 53px;
    padding: 5px;
}


<div class="sitrep">
<div class="alert-status">  
 <div class="info">
  <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
  <strong>Announcement!</strong> announcement goes here.
</div>
</div>
</div>

<div id="siteHeader">my header</div>

<!-- Hero Unit -->
<div id="hero" class="hero">
    <div id="hero-content">
        <img src="content/images/logo-dt.png" class="img-responsive">
        <a class="button" role="button" href="#base">Learn more</a>
    </div>
</div>

Answer №1

You seem to have confused class and ID attributes.

While your HTML element has the ID of sitrep, you are applying styles to elements with the class of siterep.

To resolve this, consider one of the following solutions:

Option 1 - Modify the element attribute: Change <div id="sitrep"> to <div class="sitrep">

Option 2 - Adjust the CSS to target the correct elements: Change .sitrep { to #sitrep {

Happy coding!

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

Tips for creating boxes with clearly defined edges on shared sides using three.js

When I draw boxes with common sides, I don't see the common edges, but rather perceive them as a single object even though there are 25 boxes: https://i.sstatic.net/gE8FW.png function box(scene, x, y, z, size) { const points = []; ...

Updating displayed images in HTML using Python and Flask based on passed data

return render_template('homepage.html',imgName=filenameD) PYTHON <img src= {{ name }} alt="something" style="width:500px;height:600px;"> HTML I am attempting to dynamically change the image displayed on my website usi ...

Why is the CSS functioning on JSFiddle but not on my local machine or remote website?

One of the issues I am facing with my website is related to the css menu. The dropdown items are visible, but when attempting to click on them, the dropdown closes immediately. Interestingly, the navigation functions properly on JSFiddle here. However, t ...

Foundation 5.2.2: Creating a Dropdown Menu

Would it be possible to achieve this effect using Foundation: https://i.stack.imgur.com/UyYqK.png ? I am interested in implementing 2 COLUMNS in the TopBar Menu: foundation.zurb.com/docs/components/topbar.html I came across a MegaMenu (codepen.io/winghou ...

An innovative approach for converting CSS animations to flutter projects

During a recent collaboration with fellow designers, they shared some CSS animation examples from CodePen that needed to be integrated into our current project. The animations ranged from simple to complex, like the following: * { margin: 0; padding ...

Please do not exceed two words in the input field

I need to restrict the input field to only allow up to two words to be entered. It's not about the number of characters, but rather the number of words. Can this restriction be achieved using jQuery Validation? If not, is there a way to implement it u ...

What's the best way to create an onclick event for a li element that includes a pseudo-element ::before

I have successfully created a Timeline using HTML and CSS elements. The visual result is as follows: My goal is to enable users to click on the second circle, triggering a color change in the line that connects the first and second circles. This color tra ...

Optimizing jQuery Dialog for Different Window Sizes

I am currently developing a responsive website and facing a challenge. I need to implement a popup for window sizes smaller than 480px, but on desktop screens, the content should be visible without being inside the popup. I want to avoid duplicating the co ...

I prefer to transmit information in HTML format rather than using Excel files

Here is my approach, however the response I am getting is a basic HTML. I attempted to duplicate successful code from method2 inside ExportReportChip() but it seems to not be functioning as expected. public ActionResult SuccessFulMethod(DateTime reference ...

Issue with plain CSS animation not functioning in NextJS with Tailwind CSS

I found this amazing animation that I'm trying to implement from this link. After moving some of the animation code to Tailwind for a React Component, I noticed that it works perfectly in Storybook but fails to animate when running in next dev. It si ...

Transform the binary image data sent by the server into an <img> element without using base64 encoding

It's been a challenge trying to find a reliable method for adding custom request headers to img src, so I'm experimenting with manually downloading the image using ajax. Here is an example of the code I am working on: const load = async () => ...

Using CSS selectors in Framework7 Vue allows for precise targeting and styling

I am currently working on developing a Cordova/Phonegap application using vue.js and the Framework7. I have been able to utilize functions like "onClick" by using the "v-on:click="OnClick" attribute within an HTML element. It's worth noting that Frame ...

The value attribute in the HTML input tag being dynamically increased by JavaScript

Hi there, can someone help me figure out how to save changes to the value attribute of an HTML input tag that is being incremented by JavaScript? Currently, every time I click on a specific element, the input field should increase by one. The problem is th ...

Unable to Retrieve HTML Element by TagName using VB

I am currently working on a project in VB that involves retrieving elements by tag names, similar to what I used to do in VBA. However, I am facing challenges as my code seems to freeze after opening a new browser window. Public ie As New SHDocVw.Intern ...

Is it possible to have animations play in reverse once they have completed running?

Hi there! I'm currently tinkering with the transitioning animations for my navigation button. I've successfully implemented the opening animation where the three bars morph into a single line and the menu slides out. Now, I'm looking to crea ...

Assigning the href attribute dynamically

How can you dynamically set the href attribute of the <a> tag using jQuery? In addition, what is the method for retrieving the value of the href attribute from the <a> tag with jQuery? ...

CSS smoothly scrolls upward within a set height restriction

Is there a way to use CSS to ensure that the scroll bar of a fixed-height message box is always at the bottom, displaying the latest entry? Currently, as more messages populate the chat box main section, everything inside remains static. The only way to v ...

I am interested in designing a navigation bar with varying background and hover colors for each individual block

I need help creating a navigation bar with different background colors and hover colors for each block. I can do this separately but not together, so please advise on how to combine both in the li class. Below is the code for the navigation bar: header ...

Is there a way to position the tooltip above the sorter icon in Ant Design (antd) component?

I'm currently working on creating a table with sorter columns using the antd framework. Can anyone guide me on how to position the tooltip above the sorter icon? Below is a snippet of my UI. https://i.sstatic.net/fGoqA.png Specifically, I included t ...

Switching the typeface within the content data

Recently, I incorporated this code: <div data-content="Reach" class="main-image"> along with the following CSS styling: .main-image:before { content: attr(data-content); I am now wondering if there is a method to adjust the font size and ...