Override the class inside the ul div

I am utilizing Dreamweaver's Spy menu without any sub items. By using a background image for "not active", another for "rollover" and attempting to apply one for "active". I have created a class for "active" and assigned it to one of the ul items. However, it is not displaying the background image for "active"; instead, it remains on the "not active" image. When I give the "active" class a background color instead of an image, it overlays the color on top of the "not active" background image. Despite this, the "active" class is functioning correctly.

The "rollover" effect is working as expected.

<!-- begin navContainer -->
<div id="navContainer" class="navPosLeft shadowRadiusNavContainer" >

<!-- begin MenuBar1 -->
<ul id="MenuBar1" class="MenuBarVertical">
<li><a href="index.html" class="active">Home</a></li>
<li><a href="#">Dental Services</a></li>
<li><a href="#">Meet The Doctor</a></li>
<li><a href="#">Our Office</a></li>
<li><a href="#">Map & Hours</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
<!-- end MenuBar1 -->  

</div>
<!-- end navContainer -->

The CSS

#navContainer {
background-color: #f0e9e0;
height: auto;
width: 148px;
padding: 10px;
}
.navPosLeft {
float: left;
margin-top: 20px;
margin-left: 20px;
}
.shadowRadiusNavContainer {
-moz-border-radius: 7px;
border-radius: 7px;
-moz-box-shadow: 3px 3px 3px #888;
-webkit-box-shadow: 3px 3px 3px #888;
box-shadow: 3px 3px 3px #888;
}

ul.MenuBarVertical
{
margin: 0;
padding: 0;
list-style-type: none;
font-size: 100%;
cursor: default;
width: auto;
}

ul.MenuBarActive
{
z-index: 1000;
}

ul.MenuBarVertical li
{
margin: 0;
padding: 0;
list-style-type: none;
font-size: 100%;
position: relative;
text-align: left;
cursor: pointer;
width: auto;
}

ul.MenuBarVertical ul.MenuBarSubmenuVisible
{
left: 0;
}

ul.MenuBarVertical ul li
{
width: 8.2em;
}

ul.MenuBarVertical
{
/* [disabled]border: 1px solid #CCC; */
}

ul.MenuBarVertical ul
{
/* [disabled]border: 1px solid #CCC; */
}

ul.MenuBarVertical a
{
display: block;
cursor: pointer;
/* [disabled]background-color: #EEE; */
color: #333;
text-decoration: none;
background-image: url(../images/vmenuitem.png);
padding-top: 0.5em;
padding-right: 0.5em;
padding-bottom: 0.5em;
padding-left: 1em;
background-position: left top;
}

ul.MenuBarVertical a:hover, ul.MenuBarVertical a:focus
{
/* [disabled]background-color: #33C; */
background-image: url(../images/vmenuitem.png);
background-position: left center;
}

.active {
/* [disabled]background-color: #FF9; */
background-image: url(../images/vmenuitem.png);
background-position: left bottom;
}

Answer №1

The hierarchy of CSS determines the importance based on your css selector. In this scenario, it seems that the issue stems from .active (a single class) having lower significance compared to the background assigned to ul.MenuBarVertical a and ul.MenuBarVertical a:hover.

If by 'active' you are referring to the current navigation item (not as in a:active), then you should increase the significance of the .active style (or use !important). Additionally, since you are utilizing the same image sprite, only the background-position needs to be altered:

ul.MenuBarVertical a.active {
  background-position: left bottom;
}

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

HTML5 full-screen API and its compatibility with different browsers

I'm curious to know the level of support for HTML5 full-screen API in popular browsers. Which is the earliest version of each browser that fully supports it? And for any browsers that don't (like IE I suppose), are there third-party libraries ava ...

Issues arise with the behavior of Bootstrap design when adapting to different screen sizes, as well as

I am currently working on designing my personal portfolio using Bootstrap. I have made some progress with the setup, but I am encountering some issues. When I resize the window, the top menu collapses into a button. However, when I click on the button, n ...

Only displaying sub items upon clicking the parent item in VueJS

I'm in the process of designing a navigation sidebar with main items and corresponding sub-items. I want the sub-item to be visible only when its parent item is clicked, and when a sub-item is clicked, I aim for it to stand out with a different color. ...

Exploring the wonders of CSS with Socialchef

Hey, I recently came across a solution on Stack Overflow where they provided code for SocialChef to convert decimal inputs into fractions. I'm wondering how I can write or incorporate some code to input fractions and mantissa as a fraction... I ...

Leveraging jQuery's Append functionality

Struggling with using jQuery's .append() method. Check out my code: $('#all ul li').each(function() { if ($(this).children('.material-icons').hasClass('offline-icon') == false) { $('#online ul').append ...

What is the reason for the malfunction of input :: - webkit-slider-thumb and input :: - moz-slider-thumb?

Designing a compact slider for enhancing user experience not limited to webkit browsers requires utilizing a scss template such as input { width: 100%; -webkit-appearance: none; -moz-appearance: none; appearance: none; height: 1vm ...

Angular JS Tab Application: A Unique Way to Organize

I am in the process of developing an AngularJS application that includes tabs and dynamic content corresponding to each tab. My goal is to retrieve the content from a JSON file structured as follows: [ { "title": "Hello", "text": "Hi, my name is ...

Adjust the size of the div to fit its content while maintaining the transition animation

I am aiming for the DIV height to automatically adjust to the text within it, while also maintaining a minimum height. However, when the user hovers their mouse over the DIV, I want the height to change smoothly without losing the transition effect. When ...

The jQuery append function does not incorporate CSS styling

I am currently facing an issue where my jQuery code successfully appends a piece of HTML, but the CSS styles are not being applied to it after the append operation. What is the correct approach to resolve this? This is the method I am using: if(listone[ ...

Get the latest html content and save it as a .html file using javascript or jQuery

Looking for a way to save an HTML page as a .html file? Having some trouble with jQuery modifications not being included in the exported file? Check out the code snippet below and let me know if you can spot what's going wrong! I'm still getting ...

Tips for invoking a controller method in HTML code

Hello, I am completely new to AngularJS, HTML, JavaScript, and CSS. Please keep your explanations simple for beginners like me. I'm facing an issue where the function "updateFilterTerm" is not being called, causing the variable "filterTerm" to remain ...

The directive code takes precedence over the controller code and is executed first

A custom directive has been implemented and is utilized as shown below: <div car-form car="car" on-submit="createCar(car)"></div> This directive is used on both the new and edit pages, each with its own controller. The EditCarController retri ...

Error Encountered: POST method not supported in ajax request using djangoIs this a

I am currently encountering an issue while trying to pass form data values through ajax. I keep getting a method not allowed error when attempting to add a comment on a blog post. The form below is located inside the blog_detail page: <form id="co ...

When I click on a link to redirect it, I am confronted with a bizarre rectangle that

When attempting to create redirects using images, I encountered a small issue. Take a look at this screenshot: https://i.sstatic.net/LgStu.pnghttps://i.sstatic.net/eEnNB.png This is the item in question: <p><div><a title="Home" hr ...

Disabling GPS with HTML5/phonegap: A step-by-step guide

Looking to create a function that can toggle GPS on and off for both iPhone and Android devices ...

Ways to align text on the left within a centered format

It seems like there is something missing here. I am struggling to align text to the left in a centered div. Below is an example of my final work: <div class="grid-row"> <img src="http://www.fununlimitedsports.com/wp-content/images/istock ...

Tips for adjusting an svg component to suit various screen sizes

I inserted the following SVG component into my HTML file. It fits perfectly on my tablet, but it's too large for my smartphone. How can we automatically adjust the size of the SVG to fit different screens? <svg viewBox="310 -25 380 450" w ...

Transform bootstrap CHECKBOX into the appearance of a bootstrap BADGE

Is there a way to create Bootstrap checkboxes that resemble bootstrap badges, while still functioning as checkboxes? I attempted to style the checkbox label as a badge, but it was unsuccessful. <head> <link rel='stylesheet' href= ...

Having trouble with jQuery div height expansion not functioning properly?

Having a bit of trouble with my jQuery. Trying to make a div element expand in height but can't seem to get it right. Here's the script I'm using: <script> $('.button').click(function(){ $('#footer_container').anim ...

Ensure that three spans are precisely aligned to occupy a single line

My dilemma is as follows: I have a line within a document that has a set width. Now, there are 3 elements involved - one <a> tag and two <span> tags. The content in the <a> tag varies in width each time it appears on the line. The thi ...