悬停导航栏时下拉菜单不起作用

时间:2018-12-17 19:46:00

标签: javascript html css

我在下拉菜单选项上遇到了问题。悬停“存储”时,该东西拒绝显示。我已经以不同的方式尝试过(某种程度上我几乎是幸运的,而另一些方面则不是那么多),但最终没有什么真正适合我的。

window.onscroll = function() {
  scrollFunction()
};

function scrollFunction() {
  if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) {
    document.getElementById("tituloh").style.fontSize = "15px";
    document.getElementById("tituloh").style.marginBottom = "70px";
    document.getElementById("tituloh").style.top = "20px";
    document.getElementById("header").style.paddingBottom = "0px";
    document.getElementById("remove").style.top = "47px";
  } else {
    document.getElementById("tituloh").style.fontSize = "30px";
    document.getElementById("tituloh").style.top = "35px";
    document.getElementById("tituloh").style.marginBottom = "100px"
    document.getElementById("header").style.paddingBottom = "0px";
    document.getElementById("remove").style.top = "50px";
  }
}
#body {
  margin: 0px;
}

#remove {
  list-style-type: none;
  background-color: black;
  margin: 0;
  padding: 0;
}

.order {
  display: inline-block;
}

#remove .opt {
  display: inline-block;
  color: white;
  text-align: center;
  font-size: 24px;
  padding: 14px 16px;
  background-color: black;
  text-decoration: none;
}

#remove .opt:hover,
.dropmenu:hover .dropbutton {
  background-color: white;
  color: black;
}

.dropmenu {
  float: right;
}

.dropmenu .dropbutton {
  font-size: 24px;
  border: none;
  outline: none;
  color: white;
  background-color: inherit;
  font-family: inherit;
  margin: 0;
}

.dropcont {
  position: absolute;
  background-color: white;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  display: none;
}

.dropcont .dropitem {
  text-decoration: none;
  width: 150px;
  height: 30px;
  margin: 5px 0;
  padding-top: 5px;
  padding-left: 5px;
  display: inline-block;
  text-align: left;
}

.dropcont a {
  text-decoration: none;
  color: black;
  font-size: 24px;
}

.dropcont a:hover {
  text-decoration: underline;
  transition: 0.5s;
}

.dropmenu:hover .dropcont {
  display: block;
}

#header {
  left: 0;
  top: 0;
  text-align: center;
  padding: 20px 5px;
  padding-bottom: 0px;
  position: fixed;
  width: 100%;
  margin: 0px;
  padding-left: 0px;
  transition: 0.2s;
  background-color: black;
  background-image: url(header/AvettBrothers-loja.jpg);
  background-repeat: no-repeat;
  background-position: 0 10%;
  background-size: cover;
  z-index: 1;
}

#tituloh {
  position: relative;
  top: 35px;
  text-shadow: -5px 5px 10px #000000;
  font-size: 30px;
  color: white;
  transition: 0.3s;
  margin-bottom: 100px;
}

.sales {
  margin-top: 300px;
}

.thumbnails {
  width: 50%;
  margin: 0 auto;
  text-align: center;
}

#tshirts,
#casacos,
#posters,
#acessorios,
#projects,
#kids {
  position: relative;
  display: inline;
  border: solid red;
  padding: 20px 0;
  margin-bottom: 100px;
}

img.contrast {
  margin: 20px 10px;
  filter: contrast(70%) opacity(90%);
  border: solid blue;
}

.textimgcentro {
  position: absolute;
  left: 0;
  top: -150%;
  width: 100%;
  font-size: 30px;
  text-align: center;
  color: white;
  text-shadow: -10px 5px 10px #000000;
  border: solid black;
}

#top {
  text-align: center;
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" ; http-equiv="refresh" content="5">
  <title>Loja</title>
  <link rel="stylesheet" type="text/css" href="loja/loja.css">
  <script type="text/javascript" src="loja/loja.js"></script>
</head>

<body>
  <div id="header">
    <div id="tituloh">
      <h1>Store</h1>
    </div>
    <ul id="remove">
      <li class="order"><a href="#link" class="opt">Home</a></li>
      <li class="order"><a href="#link" class="opt">About</a></li>
      <li class="order"><a href="#link" class="opt">Albuns</a></li>
      <li class="order"><a href="#link" class="opt">Tours</a></li>
      <li class="dropmenu, order">
        <a href="#link" class="dropbutton, opt">
						Store
					</a>

        <div class="dropcont">

          <a href="#tshirts" class="dropitem">T-Shirts</a><br>
          <a href="#tshirts" class="dropitem">Jackets</a><br>
          <a href="#tshirts" class="dropitem">Posters</a><br>
          <a href="#tshirts" class="dropitem">Accessories</a><br>
          <a href="#tshirts" class="dropitem">Side Projects</a><br>
          <a href="#tshirts" class="dropitem">Kids</a><br>

        </div>
      </li>
      <li class="order"><a href="#link" class="opt">Forum</a></li>
    </ul>
  </div>


  <br/>
  <br/>
  <br/>
  <div class="sales">Sales</div>

  <div class="thumbnails">
    <div id="tshirts">
      <img src="loja/thumbnails/tshirts.jpg" class="contrast">
      <div class="textimgcentro">
        T-Shirts
      </div>

    </div>

    <div id="casacos">
      <img src="loja/thumbnails/casacos.jpg" class="contrast">
      <div class="textimgcentro">
        Jackets
      </div>
    </div>

    <div id="posters">
      <img src="loja/thumbnails/posters.jpg" class="contrast">
      <div class="textimgcentro">
        Posters
      </div>
    </div>


    <div id="acessorios">
      <img src="loja/thumbnails/acessorio.jpg" class="contrast">
      <div class="textimgcentro">
        Accessories
      </div>
    </div>

    <div id="projects">
      <img src="loja/thumbnails/project.jpg" class="contrast">
      <div class="textimgcentro">
        Side Projects
      </div>
    </div>

    <div id="kids">
      <img src="loja/thumbnails/kids.jpg" class="contrast">
      <div class="textimgcentro">
        Kids
      </div>
    </div>
  </div>
  </div>
  <br/>
  <br/>
  <br/>

  <div class="bestsell">

    <div id="top">
      <h1>Top Products</h1>
    </div>

  </div>

  <hr id="cont"> Contactos Oficiais: <br /><br />
  <a href="https://www.facebook.com/theavettbrothers/" ; target="_blank"><img src="loja/Contactos/facebook.png" ; height="50" ; width="50" ; title="Facebook" ; alt="Link para Facebook"></a>

  <a href="https://www.instagram.com/theavettbrothers/" target="_blank"><img src="loja/Contactos/insta.png" ; height="50" ; width="50" ; title="Instagram" ; alt="Link para Instagram"></a>

  <a href="https://twitter.com/theavettbros" target="_blank"><img src="loja/Contactos/twitter.png" ; height="50" ; width="50" ; title="Twitter" ; alt="Link para Twitter"></a>

  <a href="https://www.theavettbrothers.com/%22target=%22_blank%22%3E<img src=" loja/Contactos/site.png "; height="50 "; width="50 "; title="website "; alt="Link para website "></a>

</body>
</html>

我该如何解决?

还有,我如何做,以便在悬停下拉菜单的同时,“商店”仍保留白色背景和黑色文字?

谢谢!

0 个答案:

没有答案