css - 简单的 CSS 悬停问题?

标签 css

我不明白为什么我的 anchor 悬停不会导致下面的 div 框变成黄色。这是我的代码:

<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
a {background-color:Blue; width:400px; height:200px;}
#hide { width:500px; height:500px;background-color:black; }
a:hover #hide {background-color:yellow; }
</style>
</head>
<body>
<a>hover</a>
<div id="hide">turn yellow</div>
</body>
</html>

我现在很累,所以我一定是忽略了一些简单的事情

最佳答案

您正在关闭 <a>介绍前hide , 所以路径

a:hover #hide 

永远不会应用。

关于css - 简单的 CSS 悬停问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3346549/

相关文章:

CSS margin-自动布局之谜

ios - 在 iphone 浏览器上嵌入 Youtube 时应用 css

html - 如何阻止元素移动

html - Canvas 尺寸导致出现垂直滚动条

javascript - 使用缓动曲线的 Css 变换

javascript - 类型功能在选择下拉列表中不可用

css - 在不影响子元素的情况下设置背景图片的不透明度

css - 3D效果按钮悬停状态CSS(可能是bug?)

html - 将 CSS 类属性应用于 Firefox/IE 与 Chrome 中的链接元素

html - 使用 col-lg-8 bootstrap 时 margin 自动不起作用