链接没有悬停效果

时间:2016-07-14 02:01:57

标签: html css

我注意到我的标签由于某种原因没有悬停。我认为这与我正在使用的背景视频有关但不确定。这是jsfiddle,注意红色链接没有悬停。

jsfiddle

<div id="navigation">
    <ul>
        <li><a href="#">home</a></li>
        <li><a href="#">home</a></li>
        <li><a href="#">home</a></li>
    </ul>
</div>
<div class="background-wrap">       
    <video id="video-bg-elem" preload="auto" autoplay="true" loop="loop" muted="muted">
        <source src="north.mp4" type="video/mp4">
        Video not supported
    </video>
</div>  
<div class="content">
    <h1>Video Background Tutorial</h1>
    <p>This tutorial shows you how to put video as a background for your website.</p>
</div>


*{
    margin:0;
    padding:0;
}

body{
    font-family:calibri,sans-serif;
}

.background-wrap{
    position:fixed;
    z-index:-1000;
    width:100%;
    height:100%;
    overflow:hidden;
    top:0;
    left:0;
}

#video-bg-elem{
    position:absolute;
    top:0;
    left:0;
    min-height:100%;
    min-width:100%;
}

.content{
    position:absolute;
    width:100%;
    min-height:100%;
    z-index:1000;       
}

.content h1{
    text-align:center;
    font-size:65px;
    text-transform:uppercase;
    font-weight:300;
    color:#fff;
    padding-top:15%;
    margin-bottom:10px;
}

.content p{
    text-align:center;
    font-size:20px;
    letter-spacing:3px;
    color:#aaa;
}

#navigation{
    float:right;
    margin-right:100px;
    margin-top:30px;
    width:400px;
}

#navigation ul li{
    float:left;
    margin-right:30px;
}

#navigation ul li a{
    color:white;
}

4 个答案:

答案 0 :(得分:2)

这是因为 z-index

这两种方法都可以解决这个问题。

1.只需将您的课程 .content 设为z-index:-1

.content {
  z-index: -1;
}

2.只需将您的课程 .content 设为z-index:1,然后将position:relativez-index:2添加到ID #navigation

.content {
  z-index: 1;
}
#navigation {
  position:relative;
  z-index: 2;
}

要详细了解 z-index ,请检查HERE

答案 1 :(得分:0)

杰夫的代码有效,只需添加:

 #navigation ul li a:hover{
        color:red !important;
    }

答案 2 :(得分:0)

更改&#34;#navigation&#34;的CSS:

position: relative;

并添加:

z-index: 1001;

在您的代码中:

#navigation {
    float: right;
    margin-right: 100px;
    margin-top: 30px;
    position: relative;
    z-index: 1001;
}

答案 3 :(得分:0)

  

试试这个我编辑了你的代码,只需要在菜单后添加一些休息时间,否则你通过对视频标签说边距来实现这个目的

*{
		margin:0;
		padding:0;
	}
	
	body{
		font-family:calibri,sans-serif;
	}
	
	.background-wrap{
		position:fixed;
		z-index:-1000;
		width:100%;
		height:100%;
		overflow:hidden;
		top:0;
		left:0;
	}
	
	#video-bg-elem{
		position:absolute;
		top:0;
		left:0;
		min-height:100%;
		min-width:100%;
	}
	
	.content{
		position:absolute;
		width:100%;
		min-height:100%;
		z-index:1000;
		
	}
	
	.content h1{
		text-align:center;
		font-size:65px;
		text-transform:uppercase;
		font-weight:300;
		color:red;
		padding-top:15%;
		margin-bottom:10px;
	}
	
	.content p{
		text-align:center;
		font-size:20px;
		letter-spacing:3px;
		color:red;
	}
	
	#navigation{
		float:right;
		margin-right:100px;
		margin-top:30px;
	}
	
	#navigation ul li{
		float:left;
		margin-right:30px;
	}
	
	#navigation ul li a{
		color:red;
	}
  
  #navigation ul li a:hover{
		color:green !important;
	}
	
	
<div id="navigation">
  <ul>
    <li><a href="#">home</a></li>
    <li><a href="#">home</a></li>
    <li><a href="#">home</a></li>
  </ul>
</div>
<br/>
<br/>
<br/>
<div class="background-wrap">
  <video id="video-bg-elem" preload="auto" autoplay="true" loop="loop" muted="muted">
  <source src="north.mp4" type="video/mp4">Video not supported	</video>
</div>
	<div class="content">
		<h1>Video Background Tutorial</h1>
		<p>This tutorial shows you how to put video as a background for your website.</p>
	</div>