<div> issues with background display

I have created two different sections with distinct backgrounds. However, I am facing an issue where these two divs are not appearing on the webpage.

My intention is to position the Navbar at the top and have another section below it that is not linked to the Navbar. Unfortunately, the second section does not seem to be displaying at all. I would appreciate any insights on why this might be happening. Thank you in advance for your help!

                                            HTML
    <!DOCTYPE html>
    <html>
    <head>
<title>
    Hair by Michelle
</title>
<link rel="stylesheet" type="text/css" href="home.css">
 </head>
    <body>
    <div class="all">
<div class="navbar">
        <ul> <h1>Hair By Michelle</h1>
            <li class="home"><a href="#">home</a></li>
            <li class="about"><a href="#">about</a></li>
            <li class="availability"><a href="http://hairbymichelle.simplybook.me/sheduler/manage/">appointments</a></li>
            <li class="contact"><a href="#">contact</a></li>
        </ul>
</div>


    <img class="pic1" src="https://scontent-lga1-1.xx.fbcdn.net/hphotos-xaf1/v/t1.0-9/598668_4520542180477_68371292_n.jpg?oh=024b6348716dcf01475a40d0576671e7&oe=5640E0C7" alt="Photo of Michelle">
</div>      
<div class="hours">
    <h1>Hours</h1>

    </div>
</div>

                                           CSS

    body {
background: gray;
background-image: url("http://i.jootix.com/r/abstract-hair-design-abstract-hair-design-1920x1080.jpg")
    }
   .navbar {
text-align: center;
background-color: #323232;
position: fixed;
width: 100%;
z-index:100;
   }
    .navbar h1 {
text-align: center;
text-shadow: -2px 1px 13px;
color: white;
    }
   .navbar li {
display: inline;
border-right: 2px solid black;
margin: 10px;
padding-right: 25px;
color: white;
   }
    .navbar li:last-child {
border-right:none;
     }
     .navbar li a{
text-decoration: none;
text-shadow:  2px;


}
   .navbar li a:link {
color: white;
   }
   .navbar li a:visited {
color: white;
 }
  .navbar li a:active {
color: green;
  }
  .navbar li a:hover {
  color: brown;

   }
    .pic1  {
width: 200px;
height: 200px;
border-radius: 100%;
margin-top:5px;
position: absolute;
z-index: 200;

   }
   .hours h1 {
background-color: #323232;
z-index: 300;
 }

Answer №1

The content you are looking for is there, but it may be hidden behind your navbar and image. This could be due to the fact that you have set the navbar and image to position: fixed and position: absolute, causing them to be removed from the normal flow of the DOM. As a result, the <h1> element appears at the top because it is still within the regular flow of the DOM.

If you add some padding, such as padding: "150px", you may be able to make the hidden content visible again.

Consider restructuring your layout and reviewing information on positioning from sources like this link.

Answer №2

The issue with the second H1 not appearing is caused by the position: fixed style of the navbar. This positioning makes it lay over the content, including the second H1 element. To ensure that the navbar remains visible regardless of the user's scrolling behavior, you can add vertical padding to the hours div like so:

.hours {
    padding-top: 100px;
}

Answer №3

Before anything else, it is crucial to enhance your typesetting skills in order to easily navigate nested HTML structures.

For instance:

<html>
    <head>
    </head>
    <body>
        <div class="all"></div>
        <div class="hours">
            <h1>Hours</h1>
        </div>
    </body>
</html>

You can clearly see the hierarchical structure at a glance.

After organizing the layout, we may come across an extra element, unsure if it belongs under <img> or <h1>Hours</h1>.

Lastly, assuming you want to display the hours below the navbar, include the following code:

.all {

position: relative;

}

.hours {

position: relative;
top: 120px;

}

This adjustment should fulfill your needs.

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

"Troubleshooting a CSS Problem in the ADF

I've encountered a serious issue with my ADF Application starting yesterday. Everything was running smoothly until suddenly, I saw this unexpected message in my Jdeveloper Console: < org.apache.myfaces.trinidadinternal.style.util.CSSUtils> < ...

What is the best way to store client-uploaded files on the client-side using Bootstrap forms and Express server code?

Essentially, the user submits a file for upload, which is then saved on the client-side (I believe this is handled by PHP), and the upload form I am utilizing is a Bootstrap HTML form. On the server side, I am writing my code with Express. I'm feeling ...

Is there a way to integrate an After Effects animation onto my website?

Being a beginner in the world of coding, I am determined to learn by building my own personal website. However, I have encountered a challenge with after effects. I have designed an animation for the welcome screen of my website using my logo and a welcome ...

"Troubleshooting: Child Component Not Reflecting Changes in UI Despite Using Angular

My child component is designed to display a table based on a list provided through @Input(). The data is fetched via http, but the UI (child component) does not update unless I hover over the screen. I've seen suggestions about implementing ngOnChange ...

Place the image in the middle of a div

Struggling to horizontally center an image in a div, but for some reason it's just not working. I've centered images many times before, so why is it different this time? Here's what I've attempted... CSS #cabeca{ position: relative; f ...

How can I prevent my mouse click from being overridden by my mouse hover?

Currently, I am developing a Sudoku game using JavaScript and facing some challenges with mouse events. My goal is to enable users to hover over a square and have it change color, as well as click on a square to highlight the entire row, column, and quadra ...

Rotating a CSS div causes the page to scroll horizontally

Currently, I am working on creating a unique design for the footer of my website. However, when implementing it, I encountered an issue that is causing a horizontal scroll (red background added for clarity). To address this problem and prevent the page fr ...

Achieve scrollability for right column (div) using Tailwind CSS

I am having trouble getting the content in the right column to scroll vertically. Can someone please help me identify what I'm doing wrong here? <link href="https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css" rel="stylesheet"/> < ...

What steps can I take to ensure the reset button in JavaScript functions properly?

Look at this code snippet: let animalSound = document.getElementById("animalSound"); Reset button functionality: let resetButton = document.querySelector("#reset"); When the reset button is clicked, my console displays null: resetButton.addEvent ...

What is the best way to initially hide a div using slide toggle and then reveal it upon clicking?

Is there a way to initially hide the div tag and then animate it in a slide toggle effect? I attempted using display:none on my '.accordion_box' followed by show() in slideToggle, but this results in adding the CSS property display: block. My goa ...

The sorting icon cannot be substituted with jQuery, AJAX, or PHP

Currently, I am working on implementing "sort tables" using ajax, jquery, and PHP. The sorting function is functioning correctly; however, I need to show/hide the "sorting images". At the moment, only one-sided (descending) sorting is operational because I ...

The CSS styling of Vuetify TreeView does not support text wrapping

I'm having trouble getting the long text in this CodePen snippet to break and wrap properly. It extends off screen, rendering the append button unclickable. I've experimented with various CSS rules but haven't found a solution yet. Check ou ...

Tips for positioning an element so that it remains anchored to the content it is placed within

Hey Everyone! I'm struggling a bit with how to position the h2 headings in my code so that they stay fixed in the top right corner of the box while moving along with the rest of the contenthttps://i.stack.imgur.com/OOVaA.png%60 What I'm attempt ...

Unexpected behavior observed with field alignment

I've been attempting to align the field in an Angular HTML page, but it's not working out as I expected. Here's how the HTML file looks: <div id="report-prj-search"> <div class="dx-fieldset flex-column"> <div class="fle ...

Arranging extensive menu sections and content containment

I am currently working on enhancing my website's navigation by creating a mega menu. However, I am facing issues with the organization of the divs containing the ul content. In the fiddle linked below, you can see that "Africa", "Asia", and "Oceania" ...

AngularJS 1: Dynamically updating input values in real-time

Hey everyone, I'm experimenting with Angular and have encountered a roadblock. I am trying to assign values to an input element using ng-repeat for a list of parameters. <input type="text" ng-model="parameters.inParameterName" class="form-control ...

Creating a mesmerizing parallax effect for your image: A step-by-step guide

Looking for help to create a parallax effect on an image when hovered over. Does anyone have any advice or resources? Feeling frustrated at the moment. Here is an example link for reference: http://codecanyon.net/item/jquery-moving-perspective/full_scre ...

What is the best way to eliminate an unassigned margin from my layout?

The content of my css file is as follows: .menu { background-color: black; color: white; height: 100px; opacity: 0.5; } html { background-image: url('image.jpg'); background-size:cover; } Despite the lack of text ...

The problem arises when the body/html element is narrower than the browser window

I encountered a strange issue while working on a website for a client/design studio. Despite setting the body and html elements to a width of 100%, I noticed that when I resize the browser, a scrollbar appears forcing me to scroll right. Upon scrolling, I ...

Share your Facebook link with dynamic parameters

When attempting to create a share URL with GET parameters, I am encountering some issues with double encoding. <a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.bing.com%2Fsearch%3Fq%3Dkeyword" /> This results in a faulty URL, while &l ...