Styling menus with CSS

I'm struggling with a CSS issue while attempting to add a 1px solid black line after each element in my drop-down table menu. The current appearance of my menu is causing some trouble.

What I desire for it to look like involves applying border: 1px solid black; within the .menu li a { } section, but I don't want this style to affect the draft button since it's displaying a double border as seen in the picture.

How can I resolve this dilemma?

code snippet for the drop-down component shown:


.menu .dropdown_1col {
    margin:4px auto;
    left:-999em;

    position:absolute;
    background:#F4F4F4;
     border: 1px solid black;
    text-indent:15px;
    background: -moz-linear-gradient(top, #EEEEEE, #BBBBBB);
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EEEEEE), to(#BBBBBB));
}

   .menu li {
        float:left;
        text-align:center;
        position:relative;
        padding: 4px 10px 4px 10px;
        margin-right:30px;
        margin-top:7px;
        border:none;

    }
    .menu li:hover {
        z-index:2;
        background:#F4F4F4;
        border:1px solid #aaaaaa;
        padding: 4px 9px 4px 9px;


        /* CSS 3 Stylings */

        background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE);
        background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F4F4F4), to(#EEEEEE));

    }
    .menu li a {
        color: #EEEEEE;
        outline:0;
        text-decoration:none;
        display:block;
        text-shadow: 1px 1px 1px #000;


    }
    .menu li:hover a {
        color:#161616;
        text-shadow: none;
    }
    .menu li .drop {
        padding-right:21px;
        background:url("img/drop.png") no-repeat right 8px;
    }
    .menu li:hover .drop {
        padding-right:21px;
        background:url("img/drop.png") no-repeat right 7px;
    }
    .menu li:hover div a {
        color:#444;
    }
    .menu li:hover div a:hover {
        color:#777;
    }
    .menu li ul li a:hover {
        color:#777;
    }

Answer №1

Transform it to:

{
    .........
    outline: 1px 0px solid #aaaaaa;
    .........
}

By using 'outline' instead of 'border', you can independently set the width of vertical and horizontal borders. Additionally, you have the flexibility to specify individual border-top, border-left, etc.

Answer №2

In order to prevent this issue, you may consider the following solution:

Custom CSS

    .menu li a{
      border:none;
    }

Alternatively

   .menu li{
      border:none;
    }

This means you need to choose one of the options. Please only implement one. If you decide to use a border for ".menu li", then there is no need to apply a border for ".menu li a", or vice versa.

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

Equal spacing title in horizontal menu with Bootstrap design

Is there a way to evenly distribute menu links with varying text lengths in equal width bootstrap columns? Adjusting the column class between col-md-1 and col-md-3 doesn't seem to give accurate spacing. If you want to see, I've set up a fiddle h ...

Text that is selected within a contenteditable div: Find the beginning and end points of the highlighted text

<div contenteditable="true">This text is <b>Bold</b> not <i>Italic</i> right?</div> For instance, if the text appears in a bold format, but not italic and the user selects it, how can I determine the exact position ...

The dimensions of the image are determined by its orientation

I am working with two different types of images on my website: vertical and horizontal. Currently, I have a JavaScript function that adjusts the height of all images to fit the screen size. However, I would like to modify this function so that it also adap ...

What is the best method for locating the innermost element of an HTML tree that has a specific class assigned

I am working on a project that involves a menu system. One of the features I am implementing is that when a tree within the menu is opened, it receives the "active" class. My goal now is to dynamically retrieve the deepest sub-menu within this structure ...

When you zoom in or out, HTML5 elements styled with CSS will dynamically adjust

Hey everyone, I have a question about a problem I'm facing with my HTML and CSS page. The issue is that when I zoom in, the "Section" part moves underneath the nav bar, and when I zoom out, the footer moves next to the section part... Below is a sni ...

Flexbox: Arrange header and footer in a sidebar layout using flexbox styling

In my content layout, I have structured the sections as header, content, and footer. While I want to maintain this order for small devices, I am looking to shift the header and footer to the sidebar on desktop. I have already implemented this using floats ...

Utilizing the CSS grid framework to efficiently create repetitive rows and columns in code

When I work with CSS frameworks like Bootstrap or Materialize, I often find myself repeatedly typing the same HTML code: <div class="row"> <div class="col s12"> <!-- Some text/ a button / something --> </div> </d ...

Guide on shifting an element into a different one with the help of jQuery

I'm attempting to relocate an element within another in order to enable a css :hover effect. <ul> <li id="menu-item"> //move into here </li> </ul> <div class="tomove">...</div> 'tomove' is set to dis ...

The slider's border-radius is not being maintained as it moves from left to right

We recently implemented a slider on our website, located at . While we added a border-radius to the slider, we noticed that when the images slide, the border-radius is slightly removed... I attempted to contain the parent element with overflow: hidden, bu ...

Guide on utilizing getelementsbytagname for retrieving LI values

As I attempt to locate a specific product on amazon.com, my goal is to extract the ASIN for each item. This particular code snippet runs through various search options and retrieves the price of each product from Amazon one by one. However, in addition to ...

Transform the look of an inactive hyperlink

Can the visual style of an HTML link be modified when it is disabled? For instance, by implementing something like this: a.disabled { color:#050; } <a class="disabled" disabled="disabled" href="#">Testing</a> The code snippet above appears ...

Hover effect not activating on image within modal

only img:hover is working, but after adding this to the CSS: #user-profile #user-myModal .modal-body img:hover #user-profile #user-myModal .modal-body .change-pic i{ display: block; } it's not working. I changed the class and id names, tried eve ...

Submitting forms with Ajax without reloading the page can cause errors in Internet Explorer

Simply put: Upon clicking the login button in Firefox, Chrome, or Safari, the form is submitted correctly, running a validation via ajax and opening a new page. However, in Internet Explorer (version less than 9), the submission attempts to post to the c ...

Adjust the dimensions of the thead, tbody, and td elements on the fly

I've implemented this property in a .css file on the table shown below and there are 9 records. .fixed tbody td, thead th { width: 5.2%; float: left; } In my scenario, when there are 4 columns, the width should be 23.2%; for 5 columns ...

What is the process for using AJAX and PHP to upload an image file?

I'm facing an issue where I want to insert an uploaded image into a database with user details for a profile picture. The output I receive currently shows {"current_field":null,"field_count":null,"lengths":null,"num_rows":null,"type":null}. How can th ...

What is the best way to eliminate the unwanted white space below the footer on a webpage

I'm working on a website and I've noticed that at the end of the footer, there is a large block of white space that shouldn't be there. I've tried adjusting the HTML and CSS code, but nothing seems to fix the issue. Strangely, other pag ...

Unable to retrieve the values from document.getElementById("") or document.getElementById("").innerHtml appears to be malfunctioning

I am currently working on an HTA application that includes multiple <input type="text"> fields for users to input data. My goal is to pass this data to a VBScript for processing. Below is the HTML structure: <div id="tableContent" name="tableCon ...

Angular Delight: Jaw-Dropping Animation

After setting up my first Angular project, I wanted to incorporate Angular Animations to bring life to my content as the user scrolls through the page. I aimed to not only have the content appear on scroll but also implement a staggering animation effect. ...

Remove the </div> text and replace it with nothing

I'm attempting to substitute the end tag div with an empty string. Here is my code: $('#textDiv').html().replace(/'</div>'/g,'').replace(/<div>/g,'\n') This is the HTML: <div id='tex ...

jquery to create a fading effect for individual list items

I have a group of items listed, and I would like them to smoothly fade out while the next one fades in seamlessly. Below is the code I've been working on: document.ready(function(){ var list_slideshow = $("#site_slideshow_inner_text"); ...