The initial selection in my dropdown menu is highlighted

I am attempting to create a CSS dropdown menu for the first time. I have encountered some issues along the way. The dropdown menu appears correctly with a red background color, but the first item displays a different background image instead of the red background like the rest. Can someone please review this code on jsfiddle or elsewhere and provide some guidance on how to fix it?

<html>
<head>
    <link rel='stylesheet' type='text/css' href='css/styles.css' />
    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'>    </script>
</head>
<body>
<div id='cssmenu'>
<ul>
   <li><a href='index.html'><span>Home</span></a></li>
   <li><a href='team'><span>Team</span></a>
       <ul>
            <li><a href='team'>Team</a></li>
        <li><a href='team'>Team2</a></li>
        <li><a href='team'>Team3</a></li>
       </ul>
   </li>
   <li><a href='sponsors'><span>Sponsors</span></a></li>
   <li><a href='first'><span>First</span></a></li>
   <li><a href='contact-us'><span>Contact Us</span></a></li>
   <li class='last'><a href='handouts'><span>Handouts</span></a></li>
</ul>
</div>
</body>
</html>

AND THE CSS:

#cssmenu ul {
  list-style-type: none;
  position: relative;
  display: block;
  font-size: 12px;
  background: url(../images/bg.png) repeat-x top left;
  font-family: Verdana, Helvetica, Arial, sans-serif;
  border: 1px solid #000;
  margin: 0;
  padding: 0;
  width: auto;
}
 #cssmenu li {
  display: inline-block;
  margin: 0;
  padding: 0;
}
 #cssmenu li ul {
     position: absolute;
     display: none;
}

 #cssmenu li ul li {
display: block;
}

 #cssmenu li:hover ul {
display: block;
 }
#cssmenu li a {
  display: block;
  color: #A79787;
   text-decoration: none;
   padding: 9px 15px;
 font-weight: normal;
 }
#cssmenu li a:hover,
#cssmenu .active {
  color: #fff;
  background: url(../images/bg.png) repeat-x top left;
  text-decoration: none;
}
#cssmenu .active a {
  color: #fff;
  font-weight: 700;
}
 #cssmenu ul {
  background-color: #B11718;
}
#cssmenu li a:hover,
#cssmenu li.active {
  background-color: #DE3330;
}

Any help in resolving this issue would be greatly appreciated. Thank you.

Answer №1

To update the style, switch from using background-color to just background.

#navbar li a:hover,
#navbar li.active {
background: #DE3330;
}

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

The ng-show animation is not functioning as anticipated

I've put together this Plunker, but I'm having issues with the enter and leave animations... The enter animation seems to be delayed, while the leave animation doesn't seem to work at all. Here is the CSS style: div.ng-enter { ...

Modify the parent div's background color on mouseover of the child li

I want to update the background image of a parent div that contains a series of ul li elements. Here is the HTML code I am working with: <section class="list" id="services"> <div class="row"> <ul> <li>& ...

Determining the visibility of an element on a webpage using JavaScript and Puppeteer

I've created a framework that scans websites hosted on our servers to ensure they comply with our policies. If any prohibited content is found, we capture a screenshot along with other relevant details. However, taking a screenshot may not be possibl ...

What are the steps to increase the size of the search bar?

I have been working on this code, but I am struggling to align the search bar properly within the navigation bar. Can someone please guide me on how to achieve this? I apologize for my lack of coding expertise, as I am new to Information Technology and s ...

The JSON ticker for BTC/LTC has stopped functioning

I've been relying on this JSON ticker for the past month and it's been smooth sailing. However, today it suddenly stopped working. Any ideas on what might have caused this issue? $(function () { startRefresh(); }); function startRefresh() { ...

Adjust the order of list items based on the resolution change

Is there a way to rearrange the order of the list items in an ul when the screen resolution changes, specifically having the last li appear in the first place? Edit: I am attempting to achieve this by using flexbox. .postpreview ul { list-style: none; d ...

Borders in my CSS/HTML table design

Hey, I'm currently facing an issue with my class project. I've created a table with a series of images to form a background image. However, there are borders on the table that I need to adjust. Here is the current look: I am trying to have a sq ...

Tips on incorporating form groups within a grid using semantic-ui-react

I am currently developing a project using semantic-ui-react that involves numerous input fields. To better organize the page, I have decided to split it into 3 columns. Below is the approach I have taken: render() { return ( <Form> < ...

Tips for changing the text in a .txt file that has been accessed through a $.get request

Is there a way to read and open a file, but update a specific value within it? For example, if my data.txt looks like: [ {"slot": "1", "name": "Bob"}, {"slot": "2", "name": "John"} ] and I want to update it with a query like: "UPDATE data.txt SET na ...

Adjusting the placement of a div based on the height of a table

I recently created a dynamic table where rows are inserted dynamically. One issue I am facing is that when the table height increases due to more rows, a div below the table does not show up in the desired position. How can I set the position of the div so ...

Ensure that the top border is aligned perfectly with the top of the page while keeping the text in its

I am a beginner student working on my very first project, so I appreciate your patience as I learn. Currently, I am trying to add a hover effect to the navigation bar links where a blue bar appears at the top of the link and touches the border of the page ...

Experiencing issues with archiving files in PHP and receiving a 'zipArchive::close() Read Error: no such file or directory in c:/' error message?

When using PHP to download multiple files as a zip folder, the code below is giving me an error message: "zipArchive::close() Read error: no such file or directory in C:// path" I have added an HTML button that, when clicked, retrieves the id of the row t ...

Prevent the Focus on Submit Button in CSS

Whenever a text field is focused in Opera, the submit button ends up with an unsightly black border. A screenshot clearly shows this issue. At the bottom of the image, you can see how the textarea is focused and the submit button looks unappealing. Is th ...

Displayed in the xmlhttp.responseText are the tags

Why do tags appear when I input xmlhttp.responseText into my textbox? It displays <!DOCTYPE html><html><body></body></html> along with the desired content. Is there a way to prevent the tags from being displayed? Here is the ...

"Enhancing Your Website with Dynamic CSS3 Div Animations

Seeking assistance in displaying an empty div after a CSS3 Animations loading circle has completed. Any guidance is welcome! jsFiddle ...

Building a sturdy base with foundation 6 and incorporating blank columns for

I wanted to format my columns like this: | TEXT | TEXT | TEXT | TEXT | BLANK | BLANK | so I implemented it in the following way: <div class="row"> <div class="columns medium-4 large-2">TEXT</div> <div class="columns medium-4 lar ...

Is there a way to remove identical individual rows from the dataset?

Can someone help me? I am trying to display only the unique values of Barangay, specifically 'Talojongon', without any duplicates. Currently, my output looks like this: | Barangay | Disease | __________________________________ | Ta ...

The Jquery animate function is not compatible with the transform property

I am facing an issue with the Jquery animate function. Despite trying various solutions, I have been unable to get it to work. Below is the HTML code that I have used: <!DOCTYPE html> <html lang="en"> <head> <meta cha ...

What's the secret behind the functionality of this jQuery menu?

As I was browsing the website , I noticed that they have a menu in the top header with links like "Freebies" and "Inspiration". I searched for where the code for this menu is located, but couldn't find it. Can anyone help me locate the code? I' ...

exploring various dynamic elements using jquery

If you need some help figuring this out, take a look at the JSFiddle here. I've set it up for users to input any data they want in the text box, choose a table from set one, and then click the "submit" button to send it. <div> <Div> < ...