gpt4 book ai didi

html - 悬停或访问时链接不会样式化

转载 作者:行者123 更新时间:2023-11-28 04:09:05 25 4
gpt4 key购买 nike

我的问题是为什么菜单中的链接在悬停或访问时没有设置样式。这个元素的唯一特点是菜单位于标题内,它本身仅在悬停时显示(我创建了一个“可悬停的”不可见 div,不知道更好的方法)。我猜这两种“悬停”状态(?)之间存在某种冲突,一种是包含链接的 header ,另一种是链接本身。这是它的外观的 gif:

enter image description here

代码如下:

@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”被应用,但已访问或悬停的链接上没有颜色。知道为什么吗?感谢您的宝贵时间

最佳答案

尝试:

.......
#hoverable:hover #header #title h1 #parana {
color: rgba(255, 255, 255, 1);
top: 0px;
}

// my code (start)
#hoverable #menu ul li a {
color: white;
}
#hoverable #menu ul li a:hover {
/* color: rgba(255, 255, 255, 1); */
color: red;
}
// my code (end)

#title {
margin-left: 10vw;
line-height: 10vh;
float: left;
}
.......

关于html - 悬停或访问时链接不会样式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42808625/

25 4 0
文章推荐: C++ 二叉搜索树创建段错误
文章推荐: html - 如何让文本居中以及如何让
文章推荐: html - DIV 操作
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com