【发布时间】:2017-08-06 02:59:55
【问题描述】:
我的问题是为什么菜单中的链接在悬停或访问时没有设置样式。该项目的唯一特点是菜单位于标题内,它本身仅在悬停时显示(我创建了一个“可悬停”的不可见 div,不知道更好的方法)。我猜这两个“悬停”状态之间存在某种冲突(?)包含链接的标题之一和链接本身之一。这是它的 GIF:
这里是代码:
@font-face {
font-family: Eagle-Light;
src: url("Eagle-Light.otf") format("opentype");
}
@font-face {
font-family: Raleway Light;
src: url("Raleway Light.otf") format("opentype");
}
.cf:before,
.cf:after {
content: "";
display: table;
}
.cf:after {
clear: both;
}
html,
body {
margin: 0px;
padding: 0px;
height: 100vh;
}
#header {
position: absolute;
width: 100vw;
height: 10vh;
background-color: rgba(0, 0, 0, 0);
opacity: 1;
z-index: 6;
top: -40px;
transition: top 1s ease, background-color 1s ease;
}
#hoverable {
position: absolute;
height: 10vh;
width: 100%;
z-index: 7;
}
#hoverable:hover #header {
background-color: rgba(0, 0, 0, .3);
top: 0px;
}
#hoverable:hover #header #title h1 {
color: rgba(129, 129, 129, 1);
top: 0px;
}
#hoverable:hover #header #title h1 #parana {
color: rgba(255, 255, 255, 1);
top: 0px;
}
#hoverable:hover #menu ul li a {
color: rgba(255, 255, 255, 1);
}
#title {
margin-left: 10vw;
line-height: 10vh;
float: left;
}
#footer {
position: relative;
height: 10%;
width: 100%;
background-color: red;
display: none;
opacity: .5;
}
#container {
height: 100%;
width: 100vw;
background-color: white;
min-height: 580px;
text-align: center;
background-color: blue;
}
.notVisible {
opacity: 0;
}
.visible {
opacity: 1;
transition: opacity 0.7s ease-in-out;
}
#imagewrap {
position: relative;
z-index: 5;
display: inline-block;
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
#front {
position: absolute;
top: -9999px;
bottom: -9999px;
left: -9999px;
right: -9999px;
margin: auto;
height: 110%;
}
#container #imagewrap:hover .buttons {
opacity: 1;
}
.buttons {
cursor: pointer;
z-index: 3;
opacity: 0;
transition: opacity .3s ease-in-out;
top: 50%;
transform: translateY(-50%);
}
#previous {
left: 5px;
background-image: url(Images/carremoins.png);
background-repeat: no-repeat;
background-position: center center;
width: 20px;
height: 20px;
z-index: 4;
position: absolute;
}
#next {
right: 5px;
background-image: url(Images/carreplus.png);
background-repeat: no-repeat;
background-position: center center;
width: 20px;
height: 20px;
z-index: 4;
position: absolute;
}
#tag {
position: relative;
height: 40px;
line-height: 1.7em;
padding-top: 5px;
text-align: center;
font-size: 1.1em;
}
p {
color: #818181;
font-family: Eagle-Light;
line-height: 1.7em;
padding: 0px;
margin: 0px;
font-size: 0.5em;
letter-spacing: 0.21em;
}
h1 {
color: rgba(129, 129, 129, 0);
transition: color 1s ease;
font-family: Eagle-Light;
height: 100%;
margin-top: 10px;
padding: 0px;
margin: 0px;
font-size: 2em;
letter-spacing: 0.3em;
padding: auto 0;
}
#parana {
color: rgba(255, 255, 255, 0);
transition: color 1s ease;
}
#menu {
line-height: 10vh;
float: right;
margin-right: 5vw;
}
li,
ul {
padding: 0;
margin: 0;
list-style: none;
float: right;
}
li a {
display: block;
line-height: 10vh;
padding: 0 1em;
font-size: 1.3em;
color: rgba(255, 255, 255, 0);
transition: color 1s ease;
text-decoration: none;
}
ul {
margin-right: 2em;
}
a:visited {
text-decoration: none;
color: pink;
}
a:hover {
color: red;
}
#bgvid {
position: fixed;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
transform: translateX(-50%) translateY(-50%);
background-size: cover;
}
@media screen and (min-width: 1450px) and (max-width: 1675px) {
#front {
height: 900px;
}
}
@media screen and (min-width: 1675px) and (max-width: 2000px) {
#front {
height: 1000px;
}
}
@media screen and (min-width: 2001px) {
#front {
height: 1100px;
}
}
<audio autoplay>
<source src="paranaMusic.mp4" type="audio/mpeg">
</audio>
<video playsinline autoplay id="bgvid" class="visible">
<source src="Images/01PARANA/noSound.mp4" type="video/mp4">
</video>
<div id="hoverable">
<div id="header">
<div id="title">
<h1>MAX RUIZ <span id="parana">PARANÁ</span></h1>
</div>
<nav class="cf" id="menu">
<ul>
<li><a href="about.html">about</a></li>
<li><a href="gallery.html">gallery</a></li>
<li><a href="contact.html">contact</a></li>
<li><a href="shop.html">shop</a></li>
</ul>
</nav>
</div>
<div id="container">
<div id="imagewrap" class="notVisible">
<img src="Images/01PARANA/Image1.jpg" id="front" />
<div id="previous" class="buttons" onclick="change(-1);"></div>
<div id="next" class="buttons" onclick="change(1);"></div>
</div>
</div>
<div id="footer">
</div>
最让我困惑的是,选择器 a:visited 的属性“text-decoration”的值“none”正在应用,但在访问或悬停的链接上都没有颜色。知道为什么吗?感谢您的宝贵时间
【问题讨论】:
-
请将代码放入jsFiddle并在此分享链接。
-
你覆盖了你的代码。一个快速而肮脏的解决方案是向悬停样式添加重要内容。 JSFiddle:jsfiddle.net/6mbtjqw9
-
这行得通。我现在如何覆盖过渡,以便我悬停的链接不会花一秒钟变成另一种颜色!
标签: html css colors hover css-transitions