所以我的代码看起来像这样:
<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
Run Code Online (Sandbox Code Playgroud)
现在它以某种方式在内联CSS中不起作用,这是我能做到的唯一事情.如果你有一个解决方案,我会很高兴.但是,我想制作:hover属性但是如何因为这不起作用:
<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;}
Run Code Online (Sandbox Code Playgroud)
要么
:hover {background: white;}
Run Code Online (Sandbox Code Playgroud)
要么
hover {background: white;}
Run Code Online (Sandbox Code Playgroud)
内联样式中不能包含伪选择器.
您需要在外部样式表(<link rel="stylesheet" href="style.css" />)中使用CSS 或使用<style>元素.