Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding css for a specific div?

Tags:

css

i have a a:hover for all my links on my page:

a:hover {
  background-color: blue;
  text-decoration: underline;
  color: black;
}

but but there are specific ones in a div that i don't want anything to happen when you hover over them, so can i do something like this?

#what_we_offer a:hover {
  background-color: none:
  text-decoration: none;
  color: none;
}

basically i don't want it to do any of the above when it hovers over them specific links.

thanks

like image 643
Mo. Avatar asked Jul 15 '10 12:07

Mo.


People also ask

How do I override a CSS class in a div?

To override an attribute that a CSS class defines, simply append a new inline style after the DIV's class definition.

How do I override a particular element in CSS?

To override the CSS properties of a class using another class, we can use the ! important directive. In CSS, ! important means “this is important”, and the property:value pair that has this directive is always applied even if the other element has higher specificity.

How do you override a style in CSS?

The only way to override inline styles is by using ! important . Many JavaScript frameworks and libraries add inline styles.

Can you overwrite CSS?

No. After a CD or CD-R is created, it cannot be edited, erased, formatted, or otherwise modified. If you've created the CD or CD-R and want to modify it, recreate it using a new CD-R. Before you continue, make sure you have another blank CD-R, so you can create the new disk.


3 Answers

Yes that should work fine, although you likely don't want to set none unless you really don't want any style... setting your base colors etc. should work fine.

#what_we_offer a:hover {
  background-color:#fff;/*presuming was originally white*/
  text-decoration:none;
  color:#000;/*presuming was originally black*/
}

PS I'm not sure if it was just a typo, but your original background-color:none: line was terminated with a colon vs. a semi-colon thus it would have caused issues.

like image 170
scunliffe Avatar answered Oct 05 '22 22:10

scunliffe


#what_we_offer a:hover {
  background-color: transparent;
  text-decoration: none;
  color: none;
}

use transparent instead of none, that works.

thanks for all the answers.

like image 42
Mo. Avatar answered Oct 05 '22 22:10

Mo.


Rather than using id with css use Class

/* for link where you want to change color on hover */
    .Link a:hover { 
      background-color: none: 
      text-decoration: none; 
      color: red; 
    } 

/* for link where you dont want to change color on hover */
    a:hover { 
      background-color: none: 
      text-decoration: none; 
      color: none; 
    } 
like image 45
Pranay Rana Avatar answered Oct 05 '22 22:10

Pranay Rana