2015-02-24 80 views
0
<html> 
<head> 
<style> 


.box { 
    float: left; 
    width: 175px; 
    height: 100px; 
    margin: 0.2em; 
    background color: DarkGray; 
} 

.head{ 
color: green; 
} 

h1{ 
color: white; 
text-align: center; 
height: 2%; 
margin-top: auto; 
margin-bottom: auto; 
} 

p{ 
color: LightSalmon; 
text-align: center; 
height: 5%; 
margin-top: auto; 
margin-bottom: auto; 
} 
a:link{ 
    text-decoration: none; 
} 
a:visited{ 
    text-decoration: none; 
} 
a:active{ 
    text-decoration: none; 
} 
a :hover{ 
    text-decoration: none;color:green;background-color: yellow; 
} 

</style> 
</head> 
<body> 
<h1 class="head"> 
MY BLOCKS 
</h1> 
<a href="https://www.google.co.uk" target="_blank"><div class="box"><h1>Block0</h1><p>It is a floating Block0</p></div></a> 
</body> 
</html> 

在這段代碼中,我需要改變我的鼠標懸停「格」的色彩......我已經試過幾乎所有的東西我在網上找到,包括從這裏提示。沒有工作。請幫忙。我能更換線路,變化瓷磚的顏色在HTML鼠標懸停時,CSS

a :hover{ 
     text-decoration: none;color:green;background-color: yellow; 
    } 

我已經試過

.box a :hover{ 
      text-decoration: none;color:green;background-color: yellow; 
     } 

a :hover box{ 
      text-decoration: none;color:green;background-color: yellow; 
     } 

a box:hover{ 
      text-decoration: none;color:green;background-color: yellow; 
     } 

等等

+2

您必須移除'a:hover'之間的空格。所以你的最終選擇器應該是:'a:hover .box {...}'。 – emmanuel 2015-02-24 14:31:10

+0

你想要達到什麼目的? – 4dgaurav 2015-02-24 14:34:46

+0

謝謝#emmanuel – 2015-02-24 14:47:06

回答

0

最好使用a標籤的懸停狀態。

a:hover .box {color:green; background-color: yellow;}