Issue with dropdown menu items inheriting CSS border from parent menu item

I am facing an issue with the drop-down menu I created, as some of the sub menu items are inheriting CSS properties from the parent menu item.

In particular, the sub menu items are picking up the blue border from the parent and the light blue background color when hovering over them.

Even though I added a red border, the blue one still shows, and the 'red' hover class I included is not being triggered.

You can view my Fiddle here: http://jsfiddle.net/oampz/W2zrn/

HTML:

<nav class="site-nav">
    <ul class="menu-nav wrap menu menu--hor">
        <ul id="main-nav">
            <li class="menu-nav--home">
                <a href="index.html" title="home"></a>
            </li>
            <li id="nav-dropdown" class="drop-down"> <a>Link 1</a>

                <ul class="visuallyhidden">
                    <li>
                        <a href="#" title="title">Link Two Sub One</a>
                    </li>
                    <li>
                        <a href="#" title="title">Link Two Sub Two</a>
                    </li>
                    <li>
                        <a href="#" title="title">Link Two Sub Three</a>
                    </li>
                </ul>
            </li>
            <li><a>Link 2</a>

            </li>
        </ul>
    </ul>
</nav>

Answer №1

To get rid of the sub menu items inheriting the blue border from their parent, make the following adjustment:

.menu-nav > li a {
  border-right: 1px solid #0d63ba;
}

This change will only apply the blue border to the anchor tags that are direct children (li items) of the ul menu-nav.

To implement a red background hover effect, update the following code snippet:

.drop-down ul li:hover a {
  background-color: red;
}

Answer №2

Don't miss out on this updated version of your fiddle: http://jsfiddle.net/W2zrn/5/

Included a few lines of code:

#nav-dropdown li a {
  border: medium none;
  padding: 0 0 0 10%;
  width:100%;
}
#nav-dropdown li {
  width: 100%;
  border: none;
}

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

What could be the reason for the misalignment between md-menu and md-button when ng-href is included in the button?

Check out the demo by clicking here: http://codepen.io/audiodude/pen/vLyNvw The main distinction between the top and bottom sections lies in the fact that the top section utilizes an md-button with an ng-href attribute, which Angular Material compiles int ...

Transitioning from feelings to sewing: incorporate a duo of properties within variations and breakpoints

I was thinking about how to convert this styled-emotion code into stitches. Essentially, I need to handle the onlyShowOnDesktop and breakpoint props. The definition of breakpoint is as follows: const breakpoint = isTopNavigationBreakPoint ? theme.defaultB ...

Importing CSS with Node Sass using npm

Instead of inlining css within sass, I attempted to utilize the npm package Node Sass CSS importer. Unfortunately, I am struggling to get it to function properly. I typically use npm as my build tool: "build:css": "node-sass some_path/style.scss some_pa ...

Tips for creating a flexbox layout that is responsive to different screen

Currently, I am using flex to ensure that the two inner div elements have the same height. However, the design is not responsive as it appears perfectly in a full-width window but gets squeezed on mobile devices. Is there a solution to this issue? Are th ...

What is the process for submitting a form to a PHP page?

Could you assist me in posting a form with two fields on a php page using $_POST['json']; where the object will be of json type? <div id="result"></div> <form name="form" id="form" method="post" > Name: <input type="text ...

How to prevent click events and still enable scrolling within a DIV using CSS/JS

Basically, I am looking to enable scrolling within a DIV while also disabling click events. Any suggestions on how this can be achieved? Appreciate any help! ...

My mobile website, built using Bootstrap, appears as if it is zoomed

I recently launched a website called dekhbehen.com, where users can download wallpapers and generate memes. One issue I have encountered is that when the site is accessed via smartphone, it appears zoomed out. You can visit the specific URL causing this ...

Tips for inserting multiple numbers from a single row into separate options within a SELECT statement

Is there a way to create a select box with multiple options that are based on one row from my MySQL table? For example, <?php if(!empty($row['size'])) { ?> <label>Size</label> ...

Retrieve various pieces of input data

Here is my jQuery code: $(document).ready(function() { var max_fields = 10; //maximum input boxes allowed var wrapper = $(".input_fields_wrap"); var add_button = $(".add_field_button"); var x = 1; //initial text box coun ...

Identify the browser dimensions and implement CSS styling for all screen resolutions

I am currently facing an issue with a function that I have created to apply CSS changes to a menu based on browser resizing and different resolutions. The problem lies in the fact that my function does not seem to be correctly interpreted by the browser. W ...

Bootstrap 3 Implementation of a Clear Navbar

I'm trying to create a transparent navbar using the code below: <div class="navbar navbar-default navbar-fixed-top" style="top:50px; background:transparent;"> <div class="navbar-inner"> <div class="container"> <ul cla ...

Troubleshooting the Full Height Feature for Sidebar (Panel) in Twitter Bootstrap

I'm having issues with the Sidebar (Panel) in Twitter Bootstrap. I'm encountering some trouble with how it is displayed. Below is the CSS code I am using for the sidebar: .sharecartside .content { height: 100% !important; min-height: 10 ...

The radio button default selection is checked, but the desired styles are not being applied

My webpage features two radio buttons, "No" and "Yes," with the default selection being "No." I have implemented CSS styles for the checked elements, but they only work once physically selected. My goal is to apply these styles immediately on page load wit ...

Incorporating JavaScript and Alpine.js to Monitor and Log Changes in Input Range Values

I have developed a basic app that logs the input range value to the console when the range input changes. Interestingly, it works flawlessly when I slide the slider left and right with my cursor. However, when I programmatically change the value using Ja ...

Concealing Columns in the Beta version of Bootstrap 4

Currently utilizing Bootstrap 4.0 Beta for website design, encountering a roadblock with a responsive-utility feature. In previous Bootstrap 3 versions, it was achieved using classes like: hidden-xs, hidden-md, among others. The addition of -up and -down ...

Utilize Jquery to transfer a JSON API Request element to an array

Currently, I am immersed in a project where I am learning how to utilize APIs and extract data from them. However, I have encountered an issue with getting a specific element from the JSONP result that I am receiving. My goal is to extract only the address ...

Having trouble getting the smooth scroll-behavior to work properly in Tailwind CSS?

I've been working on my portfolio using next.js and tailwind CSS. I've added scroll-behavior: smooth in the globals.css file, and in the Navbar, I used https://i.stack.imgur.com/wqb4t.png I really want to achieve that smooth scrolling effect thr ...

Tips for Retrieving Html Element Attributes Using AngularJS

Update: Even though the discussion veered off track, the main question still stands - how can I access an attribute of an HTML element within an Angular controller? Check out my attempt on Plnkr: http://plnkr.co/edit/0VMeFAMEnc0XeQWJiLHm?p=preview // ...

Why do the fontawesome icons fail to appear in my SVG file?

I've encountered a peculiar issue where icons (from fontawesome) are not appearing in my svg. They have always displayed correctly on my personal computer, so for a while I didn't realize that others were having trouble seeing them. For instance ...

How can I prevent the repetition of a background image causing empty spaces?

Encountered an issue with a repeating background image. In instances where the content is relatively short, shorter than the height of the screen, the background image continues to repeat for the remaining space. Please refer to the accompanying screensh ...