Odd behavior from CSS

Running into a bit of a snag with my website lately, specifically with the CSS. As I'm relatively new to web design, these issues tend to crop up more frequently. Usually, I can solve them on my own, but this one has me completely puzzled.

What's happening is that the last two elements in the unordered list are unexpectedly pushed down (see image below). I've tried various fixes, including adding a class and manually adjusting it, but nothing seems to work.

Additionally, I've noticed that the problem only occurs in IE 9.0 when JavaScript is enabled (which is necessary for my sub-menu items).

Any insights or suggestions on what might be causing this issue (and hopefully an easy solution) would be greatly appreciated.

<div id="main_menu">
            <div id="main_menu_container">
                <ul>
                    <li><a href=# id="home_button">Home</a></li>
                    <li><a href=# id="products_button">Products</a></li>
                    <li class="baq"><a href=# id="baq_button">Book a Quote</a></li>
                    <li><a href=#>Gallery</a></li>
                    <li class="misplace"><a href=#>About Us</a></li>
                    <li class="misplace"><a href=#>Contact Us</a></li>
                </ul>
            </div>
        </div> <!--END OF MAIN MENU -->

Here's the CSS...

div#main_menu{
    height:45px;
    position:relative;
    z-index:11;

    /* background gradients and shadow styling */

}

div#shadow_1{
    /* shadow styling */

}

div#main_menu div#main_menu_container{
    /* container styling */

}

#main_menu #main_menu_container ul li{
    /* list item styling */

}

#main_menu #main_menu_container ul li a{
    /* anchor styling */

}

#main_menu #main_menu_container ul li.baq a{background:#3d9dff; color:white;}

#main_menu #main_menu_container ul li a:hover{
    /* hover styling */

}


li.misplace{position:relative; top:-18px;}

jQUERY Code (I'm not familiar with jQuery, so I've enlisted someone else's help for this. Understanding the advice might be a bit beyond my expertise):

$(document).ready(function(){
    // jQuery functions for products_button
});

$(document).ready(function(){
    // jQuery functions for products hover
});

$(document).ready(function(){
    // jQuery functions for products hover and mouseleave
});

$(document).ready(function(){
    // jQuery functions for home_button, baq_button, header hover   
});

Answer №1

Everything seems to be functioning properly at this link without the need for .misplace

It is possible that the issue lies in the css (or javascript) code that is not being displayed here

Answer №2

Feel free to test out the updated CSS code below, which has been tidied up and includes the necessary styles: (You can adjust the font size to your liking)

div#main_menu{
    position:relative;
    z-index:11;

    background: rgb(246,246,246);
    background: -moz-linear-gradient(top, rgba(246,246,246,1) 0%, rgba(225,225,225,1) 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(246,246,246,1)), color-stop(100%,rgba(225,225,225,1)));
    background: -webkit-linear-gradient(top, rgba(246,246,246,1) 0%,rgba(225,225,225,1) 100%);
    background: -o-linear-gradient(top, rgba(246,246,246,1) 0%,rgba(225,225,225,1) 100%);
    background: -ms-linear-gradient(top, rgba(246,246,246,1) 0%,rgba(225,225,225,1) 100%);
    background: linear-gradient(to bottom, rgba(246,246,246,1) 0%,rgba(225,225,225,1) 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6f6f6', endColorstr='#e1e1e1',GradientType=0 );

    -webkit-box-shadow: inset 0px -1px 0px 1px rgba(255, 255, 255, .2);
    box-shadow: inset 0px -1px 0px 1px rgba(255, 255, 255, .2);

}

div#main_menu div#main_menu_container{
    width: 1000px;
    margin: auto;
}

#main_menu #main_menu_container ul li{
    display: inline-block;
    list-style:none;
    margin:0px;
    padding:0px;
}

#main_menu #main_menu_container ul li a{
    display:block;
    text-align: center;
    color:#747474;
    font-family: 'Roboto Condensed', sans-serif;
    font-size:12px;
    font-weight: bold;
    text-transform: uppercase;
    width: 150px;
    line-height: 4em;
    transition:all .05s linear;
    -o-transition:all .05s linear;
    -moz-transition:all .05s linear;
    -webkit-transition:all .05s linear;
}

#main_menu #main_menu_container ul li.baq a{background:#3d9dff; color:white;}

#main_menu #main_menu_container ul li a:hover{
    background:#ffab00;
    color:white;
}

Answer №3

@user1090635 Please remove the class li.misplace{} from your code. After that, adjust the CSS for the Centered Menu as shown below for better alignment: Demo: http://jsfiddle.net/bsPrabu/EtmSW/6/embedded/result/

 
div#main_menu div#main_menu_container {
    width:100%;
    text-align:center;
    height:45px;
    margin:0 auto;
}

#main_menu #main_menu_container ul {
    display:inline-block;
    *display:inline;/* IE*/
    *zoom:1;/* IE*/
    overflow:hidden;
    text-align:left;
}

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

Are there any reliable sources for a complete list of browser CSS properties?

Is there a way to easily access a comprehensive list of CSS properties supported by specific browsers, particularly IE8? Any suggestions on where I can find this information? ...

Update the image source within a CSS element

I'm facing an issue with changing the source image of an Element. The situation is that I have a customized CSS script and I need to modify a logo image. Below, you can find the source code: https://i.stack.imgur.com/8HLCE.png The problem lies in at ...

Utilizing the .on() method in jQuery within this specific situation

I am interested in learning how to point this to the selected element (event source) within the .on() method without needing to define an anonymous event handling function. For instance, in the code below, the context of my selected element is document, m ...

Having trouble retrieving post data using Jquery Ajax post method

I'm currently attempting to perform an AJAX post using the following code snippet: <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> </head> ...

How do I start using Google Analytics: application.js, ga.js, or a beginner’s guide?

Hello there! I was wondering if anyone could provide a comprehensive guide or step-by-step tutorial on setting up Google Analytics with some examples. The information I found so far only covers signing up and obtaining a tracking code, but it doesn't ...

Activate a .click() event on a hyperlink exclusively in mobile view

Currently, I am working on a WordPress website that utilizes a Table of Contents plugin. The plugin simply identifies headings and adds them to the table of contents. I am aiming to achieve a specific functionality on my website (). When the window width ...

Verify the Ajax submission of a post request prior to transmitting any data

Currently, I am utilizing Google Tag Manager to handle form submission inside a Bootstrap modal. Due to limited backend access, I have opted for GTB to target a specific button and utilize the onClick event. <script> $(document).on('submit&apos ...

What is the best way to limit data loading when tabs are clicked in an AngularJS application?

My application has 2 tabs and all data is fetched from an API response. Initially, all data is loaded at once. The two tabs are: Tab 1 Tab 2 By default, Tab 1 is always active. I only want to load data for Tab 1 initially and not for Tab 2. When I c ...

Utilizing checkboxes for toggling the visibility of buttons in Angular

I want to dynamically show or hide buttons based on a checkbox. Here is the HTML code I am using: <input class="form-check-input" [(ngModel)]="switchCase" type="checkbox" id="flexSwitchCheckChecked" (change)=" ...

Enhance your website navigation with Bootstrap Scrolling Nav: maintain consistent section heights and highlight the active

Can you help me with an issue I'm having when clicking on the <a> link in the navigation? The anchor point seems to be misplaced as the section headline (<h2>) is not visible. Is there a way to highlight the <a> links, perhaps by add ...

An error of type 'System.Web.HttpException' occurred during the file upload process to the server

Recently, I have started learning about asp.net, ajax, and c#. I am attempting to save an image on the server using the example below: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> ...

Is JavaScript the Key to Navigating Through a Website?

I am faced with the challenge of creating a script to extract a database from a website. The website's main page features a table where each row contains a link to another page that holds the desired database. Currently, my script can successfully e ...

Implementing Mouse Scroll Click Functionality in ASP.NET with C# (Without JavaScript)

How can I add a Mouse Scroll Click (Middle Button) event in ASP.NET and C#? I have already looked into the MouseWheel Event, but it did not provide the solution I was looking for. This is the order in which mouse events occur: MouseEnter MouseMo ...

Creating a visually appealing lineup of images with CSS3 and optimal methods

Hey there, I'm diving into the world of HTML5 and CSS3 and feeling a bit lost. Can't seem to find the right solution for what should be a simple task. My goal is to create a line of clickable images/links on my website similar to how Stack Overfl ...

To send an array of input data to JQuery

I have a requirement where students need to answer questions (retrieved from a database) using a foreach loop. Once all answers are filled, I need to pass them to jQuery and then to the controller to save in the database. <div> <tbody> ...

Is using readonly attribute for HTML inputs a security concern?

Is it reliable to trust the data from an html input field set to readonly? What exactly is the purpose of using a readonly field in a form? I understand that disabled fields are not included in $_POST, but what about readonly fields? I need a way to have ...

Is there a way to extract just the JSON data from res?

While creating a search functionality to display a list of users, I encountered an error when attempting to load additional pages to show more users: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data var result = JSON.pars ...

The dropdown button becomes unresponsive when attempting to navigate within it using ajax requests

Hello fellow members of the StackOverFlow community, I recently implemented a Bootstrap 5 dropdown button to fetch tabs from the backend using AJAX. Everything was functioning correctly until I encountered an issue where, upon clicking a button within one ...

What could be causing my javascript (jquery) code to malfunction on my website?

Hey there, I'm currently working on my first website design project and I'm experimenting with something new: 1) As the page loads, it displays an image as the background. 2) When a user scrolls down past the image, the menu bar should become f ...

CSS grid challenges on a massive scale

My CSS grid timeline is currently generating around 1300 divs, causing performance issues. Is there a way to style or interact with the empty nodes without rendering all of them? I also want each cell to be clickable and change color on hover. Any suggest ...