链接在悬停或访问时赢得了风格

时间:2017-03-15 11:36:13

标签: html css colors hover css-transitions

我的问题是为什么菜单中的链接在悬停或访问时没有被设置样式。这个项目唯一的特点是菜单位于标题内,它本身只在悬停时显示(我创建了一个"可隐藏的"不可见的div,不知道更好的方式)。我猜这两个人之间存在某种冲突" hover" state(?)包含链接的标题之一和链接本身之一。这是它的外观的全貌:

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>
&#13;
&#13;
&#13;

让我最困惑的是价值&#34;无&#34;对于该物业&#34;文字装饰&#34;对于选择器a:已访问的IS正在应用,但在已访问或悬停的链接上没有颜色。知道为什么吗?谢谢你的时间

3 个答案:

答案 0 :(得分:0)

尝试:

.......
#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;
}
.......

答案 1 :(得分:0)

这是因为css规则

#hoverable:hover #menu ul li a {
  color: rgba(255, 255, 255, 1);
}

评论此部分,然后您就可以看到您的悬停&amp;参观色彩

@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>

答案 2 :(得分:0)

在定位这些锚标记时,您需要更加具体。他们被这覆盖:

#hoverable:hover #menu ul li a {
  color: rgba(255, 255, 255, 1);
}

&#13;
&#13;
@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;
}

#hoverable #menu ul li a:visited {
  text-decoration: none;
  color: pink;
}

#hoverable #menu ul li 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;
  }
}
&#13;
<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>
&#13;
&#13;
&#13;