2014-06-23 4 views
0

I'm fairly new to HTML/CSS so excuse me if this is a simple question but my a:hover (using an id and not a class) isn't working inside an a href tag but when I use it in a th tag it does.Hover не работает внутри <a href> tag

HTML

<a href='http://www.example.com' id='link1'>Example Text</a> 

CSS

#link1 a:hover { 
text-decoration: none; 
color: #E0E0E0; 
} 

The thing is that if I put it in a div and set it as a class instead of an id, it works but then moves the rest of the links afterward down a line on the page.

+0

Я думаю, что это, вероятно, потому, что вы ищете «а» ссылки внутри # link1. Попробуйте # link1: hover, возможно. – ncdreamy

ответ

3

Это потому, что вы пытаетесь найти ссылку привязки WITHIN id 'link1', а link1 IS - привязка. Попробуйте это:

a#link1:hover { 
    text-decoration: none; 
    color: #E0E0E0; 
} 

http://jsfiddle.net/kF8ey/

+1

Спасибо! Я очень ценю это <3 –

2

Your selector is incorrect. Try this:

#link1:hover { 
    text-decoration: none; 
    color: #E0E0E0; 
} 

By using: #link1 a:hover, your telling your code too look for a link named #link1 and then look for an anchor tag inside of it. Clearly you just want #link1 itself.

Soultion in a fiddle: http://jsfiddle.net/9GXg8/

Смежные вопросы