简体   繁体   English

将div(菜单和标题/按钮)置于幻灯片上方

[英]Position div (menu and header/button) above slideshow

I am making a website, where I want a slideshow on one on the pages. 我正在制作一个网站,我想在页面上放一张幻灯片。 However, since the slideshow takes up the whole page, my header and menu places itselv underneath it. 但是,由于幻灯片显示占据了整个页面,因此我的标题和菜单在其下面放置了它的elev。 I tried making a div with a link where you can press "go back", to return to the index page, but it is not possible to click the link, and it is only visible when the slideshow changes from one image to another. 我尝试制作一个带有链接的div,您可以按“返回”键返回到索引页面,但是无法单击该链接,并且仅当幻灯片从一幅图像变为另一幅图像时才可见。 The z-index on the slideshow is 1, and I tried making it 2, and the "button" 1, and vice versa. 幻灯片放映的z索引为1,我尝试将其设置为2,将“按钮”设置为1,反之亦然。 Still, I cannot come up with a solution. 不过,我无法提出解决方案。 I really hope someone will be able to help with this. 我真的希望有人能够对此提供帮助。 Thanks in advance. 提前致谢。

I'm not posting any code, but if that is preffered, just ask! 我没有发布任何代码,但是如果可以,请问一下!

CSS CSS

.h1 { font-family:GeosansLight, Verdana, sans-serif; color: #fff; font-size: 40pt; }
.m1 { font-family:GeosansLight, Verdana, sans-serif; color: #fff; font-size: 18pt; }
.m2 { font-family:GeosansLight, Verdana, sans-serif; color: #fff; font-size: 15pt; }
.m3 { font-family:GeosansLight, Verdana, sans-serif; color: #fff; font-size: 30pt; }


body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.index-bg {
    background-image: url(bild/1.png);
}

.kontakt-bg {
    background-image: url(bild/2.png);
}

.porto-bg {
    background-color: none;
}

#header {
    height: 40px;
    width: 100%;
    text-align: center;
    position: center;
}

#menu {
    height: 20px;
    width: 100%;
    text-align: center;
}

ul.menli {
    list-style-type: none;
}

ul.menli li {
    display: inline-block;
    margin: 0px 50px;
}

ul.menli li a {
    text-decoration: none;
    color: #fff;
}

ul.menli li a:hover {
    text-decoration: underline;
}

#main-left {
    height: 500px;
    width: 50%;
    float: left;
    margin-top: 100px;
    margin-left: 395px;
    background-color: none;

}

ul.mainli {
    list-style-type: none;
}

ul.mainli li{
    margin-top: 10px;
}

ul.mainli li a {
    color: #fff;
}

#main-right {
    height: 500px;
    width: 50%;
    float: right;
    margin-top: 10px;
    background-color: none;
    margin-top: 10px;
}

The button I added 我添加的按钮

#button {
    float: right;
    padding-right: 60px;
    z-index: 2;

}
a {
    color: pink;
}

Slideshow: 幻灯片:

.slideshow {
  list-style: none;
  z-index: 1;

}



.slideshow li span {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0px;
  left: 0px;
  color: transparent;
  background-size: cover;
  background-position: 50% 50%;
  background-repeat: none;
  opacity: 0;
  z-index: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-animation: imageAnimation 24s linear infinite 0s;
  -moz-animation: imageAnimation 24s linear infinite 0s;
  animation: imageAnimation 24s linear infinite 0s;

}

.no-cssanimations .slideshow li span { 
    opacity: 1; 
}

@-webkit-keyframes

imageAnimation { 
    0% 
    {
        opacity: 0;
        -webkit-animation-timing-function: ease-in;
    }
    12.5% {
        opacity: 1;
        -webkit-animation-timing-function: ease-out;
    }
    25% {
    opacity: 1;
    }
    37.5% {
    opacity: 0;
    }
    100% {
    opacity: 0;
    }
}

@-moz-keyframes
    imageAnimation { 
    0% {
        opacity: 0;
        -moz-animation-timing-function: ease-in;
    }
        12.5% {
        opacity: 1;
        -moz-animation-timing-function: ease-out;
    }
        25% {
        opacity: 1;
    }
        37.5% {
        opacity: 0;
    }
        100% {
        opacity: 0;
    }
}
@keyframes
imageAnimation { 
    0% {
        opacity: 0;
        -webkit-animation-timing-function: ease-in;
        -moz-animation-timing-function: ease-in;
        animation-timing-function: ease-in;
    }
        12.5% {
        opacity: 1;
        -webkit-animation-timing-function: ease-out;
        -moz-animation-timing-function: ease-out;
        animation-timing-function: ease-out;
    }
        25% {
        opacity: 1;
    }
        37.5% {
        opacity: 0;
    }
        100% {
        opacity: 0;
    }
}

@-webkit-keyframes
titleAnimation { 
    0% {
        opacity: 0;
    }
        12.5% {
        opacity: 1;
    }
        25% {
        opacity: 1;
    }
        37.5% {
        opacity: 0;
    }
        100% {
        opacity: 0;
    }
}
@-moz-keyframes
titleAnimation { 
    0% {
        opacity: 0;
    }
        12.5% {
        opacity: 1;
    }   
        25% {
        opacity: 1;
    }   
        37.5% {
        opacity: 0;
    }
        100% {
        opacity: 0;
    }
} 

@keyframes

titleAnimation { 
    0% {
        opacity: 0;
    }
        12.5% {
        opacity: 1;
    }
        25% {
        opacity: 1;
    }   
        37.5% {
        opacity: 0;
    }
        100% {
        opacity: 0;
    }
}


.slideshow li:nth-child(1) span { background-image: url(bild/1.png); }

.slideshow li:nth-child(2) span {
  background-image: url(bild/2.png);
  -webkit-animation-delay: 6s;
  -moz-animation-delay: 6s;
  animation-delay: 6s;
}

.slideshow li:nth-child(3) span {
  background-image: url(bild/3.png);
  -webkit-animation-delay: 12s;
  -moz-animation-delay: 12s;
  animation-delay: 12s;
}

.slideshow li:nth-child(4) span {
  background-image: url(bild/1.png);
  -webkit-animation-delay: 18s;
  -moz-animation-delay: 18s;
  animation-delay: 18s;
}

HTML on the page in question 相关页面上的HTML

<!DOCTYPE html>
<html class="porto-bg">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>

</script>
</head>

<body>

<div id="header" class="h1">
MUA: CAROLINE MIKKELSEN</div>

<div id="menu" class="m1">
<ul class="menli">
<li><a href="index.html"> forside </a></li>
<li><a href="porto.html"> portofølje  </a></li>
<li><a href="samarbeid.html"> samarbeidspartnere  </a></li>
<li><a href="kontakt.html"> kontakt  </a></li>
</ul>
</div>

<ul class="slideshow">

  <li> <span>Slide one</span> </li>

  <li> <span>Slide two</span> </li>

  <li> <span>Slide three</span> </li>

  <li> <span>Slide four</span> </li>

</ul>

<div id="button" class="m3">
<a href="index.html"> GO BACK </a> 
</div> 

</body>

</html> 

The carousel images might also been given z-index individually. 轮播图片也可能会单独指定z-index。 Please make your z-index = number of slides + 2 (container and one extra) and try 请让您的z-index =幻灯片数量+ 2(容器和一张额外图片),然后尝试

I think a correct use of positioning would solve your problem ... 我认为正确使用定位可以解决您的问题...

whenever I have a problem of this sort I always refer to W3Schools website as they have a very diverse set of info on everything ... 每当我遇到此类问题时,我总是会参考W3Schools网站,因为他们在所有方面都有非常多样化的信息...

W3Schools - CSS position Property W3Schools-CSS position属性

furthermore I find it easier to wrap elements like lists in a container div 此外,我发现将诸如列表之类的元素包装在容器div中更容易

<div class="container">

 <ul class="slideshow">
  <li> <span>Slide one</span> </li>
  <li> <span>Slide two</span> </li>
  <li> <span>Slide three</span> </li>
  <li> <span>Slide four</span> </li>
 </ul>

</div>

just so they will be easier to manipulate on the larger scheme of things .... 这样一来,他们就可以更轻松地对更大的事物进行操作。

I also noticed that you repeat some code that you can group to save a few lines like so : 我还注意到,您重复了一些代码,可以将其分组以保存几行,例如:

.m1 .m2 .m3{
  font-family: GeosansLight, Verdana, sans-serif;
  color: #fff;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM