The lower division is encroaching on the upper section

I am facing an issue getting the mid section content div to display below the top div. The bottom div is currently overlapping and showing up underneath or at the bottom of the top div.

To help you understand better, here are two images and the relevant code:

Displayed in browser:

How it should appear:

HTML Code:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="style/style.css" rel="stylesheet" type="text/css">
</head>

<body>
<div id="topBar">
    <div id="wrapper">
        <!-- top left phone number and icon start -->
       <div id="leftTop">
            <div id="facebookTop">
            <a href="#">
            <img src="images/facebook-icon.png" alt="GreatOrlandoDiscounts Become our friend on Facebook!" />
            </a>
            </div>
            <p class="topLeftNumber">Call us at: <mark class="orange">1-800-544-7646</mark></p>
        </div>
        <!--top left phone number and icon end-->
                <!--top right phone number and icon start -->
                <div id="rightTop">
                <div id="twitterTop">
                <img src="images/twitter-icon.png" alt="GreatOrlandoDiscounts Follow us on Twitter" />
                </div>
                <p class="topRightNumber">Call us at: <mark class="orange">1-800-544-7646</mark></p>
                </div> 
                <!--top left phone number and icon end-->
                    <!--Left nav bar start-->
                    <div id="leftNavBar">
                        <!--left nav dropdown start-->
                        <div id="navBarLeft">
                        <div id="dropdownContainerLeft">
                        <div id="menuLeft">
                        <ul>
                        <li class="home"><a href="http://www.ticketmomma.com">HOME</a></li>
                        <li class="attractions"><a href="http://www.ticketmomma.com/orlando-attractions.html">THEME PARKS</a>
                            <ul>
                                <li class="attractions"><a href="http://www.ticketmomma.com/walt-disney-world.htm">Disney</a></li>
                                <li class="attractions"><a href="http://www.ticketmomma.com/universal-orlando.htm">Universal Studios...
                        

Here is my CSS:

@charset "utf-8";
/* CSS Document */

body {
    margin: 0 auto;
    background-image:url(../images/body-bg.jpg);
    background-repeat:repeat;
}
... (CSS continues)

Answer №1

Seems like the missing piece is

clear:both; which is causing the bar to float upwards

If you could share the URL, I'll be able to pinpoint where this code should be added

Answer №2

It appears that the top bar position is set as relative, but what exactly is it relative to? The code does not specify a specific amount for the top, left, right, or bottom positioning. Additionally, it would be beneficial to set the clear property of the midSecWrapper to both:

#topBar {
    width: 100%;
    height: 58px;
    background-image:url(../images/top-bar.png);
    background-repeat:repeat-x;
    /* position: relative; */
    z-index:0;  
    float: left;
}

#wrapper {
    width: 980px;
    height: 501px;
    /* position:relative; */
    z-index:100;
    margin: 0 auto;
    float: left;
}

#midSecWrapper {
    margin: 0 auto;
    width: 980px;
    height: 501px;
    clear: both;
}

To see how this works, you can try it out on this fiddle.

Answer №3

Sharing my solution here for others who may be facing a similar issue. Instead of posting it in the comments, I decided to make it an answer.

To resolve the problem, I wrapped the entire top div with a #wrapperContainer and set it up as follows:

wrapperContainer {
margin: 0 auto;
width:100%;
height:505px;
}

By doing this, all elements were contained within the wrapper and I was able to position the midSecWrapper below the image successfully. Is this considered good practice or is there a "right way" to do it? As long as the website functions correctly and validates, I believe it's good to proceed.

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

Passing the value in a td element to a JavaScript function using Thymeleaf onClick

Trying to utilize "Thymeleaf" for the first time, I am attempting to pass a value to JavaScript with the following code: onclick="getPropId('${properties.id}')" The corresponding function is as follows: getPropId(inputID){alert(inputId);} Unf ...

Error encountered in Django: Unable to locate reverse for 'register' and issue with the "STATIC" parameter

Greetings fellow Django developers! I encountered an issue where the word "static" is showing up in red as an error along with % and } <body id="bg" style="background-image: url({% static 'users/images/bg.png' %});"> E ...

jQuery Ajax Load() causing screen to refresh unintentionally upon clicking

I am currently developing a web application that includes side menus. However, I am facing an issue with the functionality of these menus. Whenever I click on certain options, the entire page refreshes. For example, under my main menu "Planning the Engagem ...

The font displayed by Google looks black when viewed on iPhones, while it appears in its true color on all other

When I was optimizing my website for mobile devices, I noticed that the font size needed adjustment. Surprisingly, on Android phones, the text appeared in orange and normal, while on Safari and Chrome on iPhones, it didn't display correctly. I have i ...

Exploring the Scope of LocalStorage in Javascript

I've recently begun working with local storage and encountered some scope issues. Whenever I try to console.log(test), the second if statement returns undefined. What am I missing here? This is my current code; $("document").ready(function(){ ...

How can I arrange individual events in agendaWeek view on FullCalendar.io and then merge them all into one line?

I am using Fullcalendar.io version 2 When I switch to the agendaWeek mode, all my events are displayed on one line in each day square. As a result, the more events I have, the thinner the event blocks become. Is there a way for me to display only one eve ...

Iterate through a directory on the local machine and generate elements dynamically

I am looking to create a jQuery-UI tabs menu that includes 54 images on each tab. I have a total of 880 images stored in a folder, and it would be very time-consuming to manually insert an <img> tag for each one. Is there a way to dynamically cycle t ...

ui-router: Issue with ui-sref causing font color to remain unchanged

I've been trying to customize the font color of a navigation link using ui-router's ui-sref functionality, but I'm facing an issue. While I can change the background color by adding it to the .active class in my CSS, the font color remains u ...

Retrieve the position with respect to the browser viewport

My current scenario involves two divs, with one nested within the other. The task at hand is to determine the position of the child div in relation to the browser window. Specifically, I aim to detect when the user scrolls down and have the child div fade ...

I seem to be invisible to the toggle switch

I currently have a toggle button that controls the activation or deactivation of a tooltip within a table. Right now, the tooltip is activated by default when the application starts, but I want to change this so that it is deactivated upon startup and on ...

Aligning an Image Dynamically Inserted with JavaScript

I'm having trouble centering an image added via Javascript within a table using my embedded CSS. Can someone guide me on how to adjust the CSS to center the image in the table? I've tried setting the margin property to auto for the image, but it& ...

Fluid overlap of divs in Bootstrap framework

I am currently in the process of making style adjustments to a website at One specific change I've made is adding a top bar image. However, I've encountered an issue where the top bar graphic overlaps the navigation when the page is resized too ...

Card Resizes when Search Button is Pressed

Recently, I've delved into Bootstrap after focusing primarily on backend development. As part of my front end work, I am implementing a feature where users can search for a place and a list of nearby venues will appear in a card layout using Bootstrap ...

Guide on retrieving data from a database and showcasing it on an HTML5 webpage using the combination of jqTouch and PhoneGap

I am currently working on developing an iPhone application for mobile health using a combination of HTML5, Javascript, jQTouch, and PhoneGap. This project is part of my school assignment aimed at gaining hands-on experience in building an iPhone app with t ...

An approach to modifying the value field within an HTML input tag using Python and Selenium

The html tag below displays an input field: <input id="input-value" title="Search" type="text" value=""> My goal is to modify the value from "" to "foo". <input id="input-value" ...

Is it possible to upload files without using AJAX and instead through synchronous drag-and-drop functionality in the foreground?

Currently, my website has a standard <input type="file"> file upload feature that sends data to the backend upon form submission. I am looking to enhance the functionality of the form by allowing users to drag and drop files from anywhere within the ...

Is it better to use <div><a /></div> over <button />?

I've recently taken over the maintenance and upgrade of an existing website. One interesting aspect of the site is how it handles buttons. The html code for buttons looks like this: <div class="btn"> <a id="dv_remCont" runat="server" h ...

The parent element is not able to apply the CSS text-decoration in jQuery

Is there a way to retrieve a specific CSS property of an element, even if it is inherited from its parent? The standard jQuery method .css() can help with this. Consider the following HTML structure: <div id="container"> some text<br> ...

The close button is not functioning properly

I created a script to close my div element by clicking on the 'x' icon, but instead of deleting the div only, the whole page gets deleted. I'm not sure where I went wrong, can anyone help me? HTML <div class="note"> <span id ...

External CSS file unable to load background image as referenced

I am facing an issue with this code in my external CSS file as it doesn't seem to work at all. Strangely, when I move it internally, everything functions perfectly. Any thoughts on what could be causing this discrepancy? html { background-image:url(i ...