所以在这种情况下,我想为html制作一个标题。首先,我想隐藏标题。当我将鼠标悬停在浏览器顶部时标题显示块。
这是代码
<html>
<head>
<style type="text/css">
.atas{
top:0px;
background-color: #5F5F5F;
width: 100%;
height: 50px;
position: fixed;
right:0px;
left:0px;
visibility: hidden;
}
.menu{
text-align: center;
width: 100%;
height: 50px;
background-color: red;
}
.menu:hover .atas{
visibility: visible;
}
</style>
</head>
<body >
<div class="menu">Menu</div>
<div class="atas">
</div>
</body>
为什么它没有显示&#34; atas&#34;当我将鼠标悬停在&#34;菜单上时#div; DIV?
答案 0 :(得分:2)
如果.atas
是.menu
的子div而不是.menu:hover + .atas{
visibility: visible;
}
,则编写css的方式将有效。它是一个兄弟姐妹所以你需要这样写
+
此处
class MyVCWithAMap: UIViewController { ... // Track the state of the map user location property when going to background var trackUserLocation = false ... deinit { NSNotificationCenter.defaultCenter().removeObserver(self) } ... override func viewDidLoad() { super.viewDidLoad() ... // Register for notifications NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(appEnteredForeground), name:UIApplicationWillEnterForegroundNotification, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(appEnteredBackground), name:UIApplicationDidEnterBackgroundNotification, object: nil) } func appEnteredBackground() { // Capture map user location state viewModel.trackUserLocation = mapView.showsUserLocation mapView.showsUserLocation = false } func appEnteredForeground() { // Restore pre-snooze state mapView.showsUserLocation = viewModel.trackUserLocation } }
指定下一个兄弟
答案 1 :(得分:1)
这是Gauravs回答评论中描述的闪烁div问题的解决方案。 同时将.atas div的:hover状态设置为block。
.menu:hover + .atas, .atas:hover {
display: block;
}
这是相应的小提琴http://jsfiddle.net/Lr67ht6r/2/