我如何制作:将鼠标悬停在div风格中?

时间:2013-08-27 14:02:49

标签: html css hover

所以我的代码看起来像这样:

<div id="blackbox">style="background: black; 
width: 90px; 
height: 80px; 
color: white; 
text-align: center; 
font-family: Times; 
font-size: 20px;
position: fixed;
left: 0px;
bottom: 150px   

现在它在某种程度上无法在内联CSS中运行,这是我唯一可以完成它的工作。 如果你有一个解决方案,我会很高兴。 但是,我想制作:悬停属性,但是因为这不起作用:

<div style="background: black; 
width: 90px; 
height: 80px; 
color: white; 
text-align: center; 
font-family: Times; 
font-size: 20px;
position: fixed;
left: 0px;
bottom: 150px}

blackbox:hover {background: white;}

:hover {background: white;}

hover {background: white;}

4 个答案:

答案 0 :(得分:9)

您不能在内联样式中使用伪选择器。

您需要在外部样式表(<link rel="stylesheet" href="style.css" />)中使用CSS或使用<style>元素。

答案 1 :(得分:0)

内嵌伪代码!不可能。在嵌入式或外部样式表中尝试。

答案 2 :(得分:0)

写在css中

#blackbox:hover {
    //write something
}

答案 3 :(得分:0)

伪选择器不能内联使用。 :) 你必须在css中单独指定它。