<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

Slight Misalignment of Elements

I am attempting to align two corners of an element so that they perfectly match the corners of another element. In simpler terms, I am aiming to synchronize the corners of one element with those of another element. Below is the code snippet: ... When y ...

Run a script tag prior to displaying the modal

Currently, I am attempting to display a bootstrap modal with dynamic content. One of the values being passed to the modal is the HTML that should appear inside it. The issue I am facing is that within the HTML content being passed, there is a script tag t ...

In what format is the parameter accepted by the .getDay() method?

Here's the plan: I need to extract information from an input element with type set as date. This data will then be stored in a .json file and later parsed when the program is initiated. Subsequently, I aim to utilize the date.getDay() function to dete ...

Removing the border from a button in CSS and HTML

Looking to build a sleek and stunning website, but struggling with removing button borders. Any help would be greatly appreciated! If you'd like to check out the issue, visit this link: . I'm aiming for no button or image borders. To review my ...

Tips for aligning a Material UI FAB button in the center and keeping it in the center while resizing the window

Is there a way to center a MaterialUI FAB button and keep it centered while resizing the window? The current positioning is not centered, as seen in the screenshot below, and it does not adjust with window size changes. Below is the code for the current F ...

Concerning dilemma with a div element

I am using 2 different partial views in my main view: <div class="col-md-6"> @Html.Action("Chart", "Teams") </div> <div class="col-md-6"> @Html.Action("SeriesWinsChart", "Teams") </div> <div class="next-game"> & ...

What is the best way to implement NgClass on a single iteration within NgFor while utilizing parent/child components?

My goal is to toggle the visibility of tiered buttons when a parent button is clicked. I am using ngFor to generate three buttons on tier 1, but I'm struggling to select only the desired tier when clicked instead of affecting all of them. I've m ...

I'm wondering if there is a method for me to get only the count of input fields that have the class "Calctime" and are not empty when this function is executed

Currently, I am developing an airport application that aims to track the time it takes to travel between different airports. In this context, moving from one airport to another is referred to as a Sector, and the duration of time taken for this journey is ...

Hover over parts of an image to bring attention to them

I am interested in developing a webpage featuring a black and white image of 5 individuals. When hovering over each person, I would like them to illuminate and display relevant information in a dialog box next to them. Do you have any tips on how I can ac ...

instructions on how to showcase a text message within the fontawesome square icon

Can someone help me with styling my code? I want to display a text message inside a square box with dimensions of 1x. <span class="fa-stack fa-5x" style="margin-left:5%"> <i class="fa fa-square-o fa-stack-2x"></i> </span> ...

Toggle the font weight in a text area by clicking a button

I need help with creating a button that will change the font-weight to bold when clicked and then revert back to normal when un-clicked. However, I only want the specific part of the text area where the user clicks the button to be bolded, not the entire t ...

Transferring scope between pages without the need for an angular service definition

Looking to open a new JSP page while passing the $scope in order to utilize an array response generated in the initial page. Example from test.js file: (function() { 'use strict'; angular .module('test', []) .control ...

Jquery refuses to conceal a particular element

I've encountered this issue before, but I'm facing a problem this time. I'm attempting to create a popup that is initially hidden. When clicked, the popup does appear, but I'm unable to close it. Additionally, when trying to change the ...

I struggled to modify the image cropping code to specify a particular image

(I will attempt to explain my issue once again) I came across a script online which can be viewed at this link : Link However, I am having trouble modifying the code to suit my needs. The script currently starts working on image upload, but I want it t ...

Unable to transmit form information using HTML/JavaScript/Express Node application

I'm facing a challenge in developing an app that allows me to input event information and then display it on a map. I'm encountering difficulties at the initial stage when it comes to saving the data. Even though Chrome's Inspect tool indica ...

Managing the display of numerous ngFor components

If you're interested in learning more about the features I will include, here's a brief overview. I plan to have a project section with cards displayed for each project, all populated from a JSON file. When users click on a card on the website, a ...

issue arising where the table's border is not displaying

I'm confused about why the border of the first tbody tr's td is not visible. https://i.stack.imgur.com/Fwlv7.png I can't see any reason why the border is not showing up. Here's what I've figured out: If the natural height of th ...

Rendering the HTML5 canvas within a console environment

I am looking to create images of humans on the console using nodejs. In order to achieve images of higher quality, I require a library or module that can facilitate drawing images in the console. Some options available include imaging and console-png. How ...

Navigating websites: Clicking buttons and analyzing content

When looking to navigate a website's directory by utilizing buttons on the page or calling the associated functions directly, what language or environment is most suitable for this task? After experimenting with Python, Java, Selenium, and JavaScript, ...

The Zurb Foundation grid system is causing issues when trying to implement vertical tabs

My vertical tabs are giving me trouble when I try to nest grid or block elements, causing everything to overflow outside the element. For example, in the image below, the numbers 1,2,3 should be in the right section. <div class="row"> <div class ...