Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 转盘正在与英雄图像和导航栏合并_Javascript_Html_Css - Fatal编程技术网

Javascript 转盘正在与英雄图像和导航栏合并

Javascript 转盘正在与英雄图像和导航栏合并,javascript,html,css,Javascript,Html,Css,我正在做一个有趣的小网站。。。我已经创建了英雄形象和导航栏的帮助下,并试图添加一个旋转木马,但它似乎是融合之间的导航栏和英雄形象 参考: 带旋转木马: 我想实现的是,它应该在它下面,而不是合并在 我已经尝试了很多方法,搜索了整个StackOverFlow网站,但我似乎有一个愚蠢的大脑,无法理解这个愚蠢的问题 以下是一些源代码,以备您需要: CSS .hero-image{ background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgb

我正在做一个有趣的小网站。。。我已经创建了英雄形象和导航栏的帮助下,并试图添加一个旋转木马,但它似乎是融合之间的导航栏和英雄形象

参考:

带旋转木马:

我想实现的是,它应该在它下面,而不是合并在

我已经尝试了很多方法,搜索了整个StackOverFlow网站,但我似乎有一个愚蠢的大脑,无法理解这个愚蠢的问题

以下是一些源代码,以备您需要: CSS

.hero-image{
    background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("heroimage.jpg");
    height: 50%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    position: relative;
}
.button {
    background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 16px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    transition-duration: 0.4s;
    cursor: pointer;
}
.hero-text{
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-family: 'Ubuntu', sans-serif;
}
nav {
    background-color: black;
    height: 50px;
}
nav a {
    float: right;
    color: white;
    background-color: 1a1a1a;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    font-size: 16px;
    font-family: 'Open Sans', sans-serif;
}
nav a:hover {
    background-color: #3b86ff;
}
* {box-sizing:border-box}

/* Slideshow container */
.slideshow-container {
  max-width: 1000px;
  position: fixed;
  margin: auto;
  z-index:4;
}

/* Hide the images by default */
.mySlides {
  display: none;
}

/* Next & previous buttons */
.prev, .next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  margin-top: -22px;
  padding: 16px;
  color: white;
  font-weight: bold;
  font-size: 18px;
  transition: 0.6s ease;
  border-radius: 0 3px 3px 0;
  user-select: none;
}

/* Position the "next button" to the right */
.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
  background-color: rgba(0,0,0,0.8);
}

/* Caption text */
.text {
  color: #f2f2f2;
  font-size: 15px;
  padding: 8px 12px;
  position: absolute;
  bottom: 8px;
  width: 100%;
  text-align: center;
}

/* Number text (1/3 etc) */
.numbertext {
  color: #f2f2f2;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

/* The dots/bullets/indicators */
.dot {
  cursor: pointer;
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.active, .dot:hover {
  background-color: #717171;
}

/* Fading animation */
.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 1.5s;
  animation-name: fade;
  animation-duration: 1.5s;
}

@-webkit-keyframes fade {
  from {opacity: .4}
  to {opacity: 1}
}

@keyframes fade {
  from {opacity: .4}
  to {opacity: 1}
}
HTML

<html>
    <head>
        <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
        <link rel="preconnect" href="https://fonts.gstatic.com">
        <link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@300&display=swap" rel="stylesheet">
        <link rel="preconnect" href="https://fonts.gstatic.com">
        <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300&family=Ubuntu:wght@300&display=swap" rel="stylesheet">
        <link rel="stylesheet" href="styles.css">
        <title>
        Checkmate - Chess Tournaments Online
        </title>
        <link rel = "icon" href ="CheckmateIcon.jpeg" type = "image/x-icon">
    </head>
<body>
    <div class="hero-image">
        <div class="hero-text">
            <h1 style="font-size:50px">Checkmate</h1>
            <p>Chess Tournaments Online</p>
        </div>
    </div>
                <script>
                    var slideIndex = 1;
                    showSlides(slideIndex);
                        function plusSlides(n) {
                        showSlides(slideIndex += n);
                        }
                        function currentSlide(n) {
                        showSlides(slideIndex = n);
                        }

                        function showSlides(n) {
                        var i;
                        var slides = document.getElementsByClassName("mySlides");
                        var dots = document.getElementsByClassName("dot");
                        if (n > slides.length) {slideIndex = 1}
                        if (n < 1) {slideIndex = slides.length}
                        for (i = 0; i < slides.length; i++) {
                        slides[i].style.display = "none";
                        }
                        for (i = 0; i < dots.length; i++) {
                        dots[i].className = dots[i].className.replace(" active", "");
                        }
                        slides[slideIndex-1].style.display = "block";
                        dots[slideIndex-1].className += " active";
                        }
                </script>>
    <nav>
        <a href=#>Tournaments</a>
        <a href=#>Event Plan</a>
        <a href=#>Register</a>
    <nav>
    <div class="slideshow-container">
    <div class="mySlides fade">
        <div class="numbertext">1 / 3</div>
            <img src="img1.jpg" style="width:100%">
        <div class="text">Caption Text</div>
    </div>
    <div class="mySlides fade">
        <div class="numbertext">2 / 3</div>
            <img src="img2.jpg" style="width:100%">
        <div class="text">Caption Two</div>
    </div>
    <div class="mySlides fade">
        <div class="numbertext">3 / 3</div>
            <img src="img3.jpg" style="width:100%">
        <div class="text">Caption Three</div>
    </div>
    <a class="prev" onclick="plusSlides(-1)">&#10094;</a>
    <a class="next" onclick="plusSlides(1)">&#10095;</a>
</div>
<br>
    <div style="text-align:center">
        <span class="dot" onclick="currentSlide(1)"></span>
        <span class="dot" onclick="currentSlide(2)"></span>
        <span class="dot" onclick="currentSlide(3)"></span>
    </div>
</body>
</html>

将死-国际象棋在线比赛
将死
国际象棋在线比赛

var slideIndex=1; 放映幻灯片(幻灯片索引); 函数加滑块(n){ 放映幻灯片(幻灯片索引+=n); } 功能当前幻灯片(n){ 放映幻灯片(幻灯片索引=n); } 功能演示幻灯片(n){ var i; var slides=document.getElementsByClassName(“mySlides”); var dots=document.getElementsByClassName(“dot”); 如果(n>slides.length){slideIndex=1} 如果(n<1){slideIndex=slides.length} 对于(i=0;i 1/3 标题文本 2/3 标题二 3/3 标题三 ❮ ❯

只要告诉我做错了什么,我就可以从这里看到你在幻灯片容器上使用了
position:fixed
,而没有给它
top
属性。它将粘贴到
顶部

试试这个

/*幻灯片容器*/

.slideshow-container {
  max-width: 1000px;
  position: fixed;
  margin: auto;
  z-index:4;
  top:50px;

}

 <body>
<nav>
  <a href="#">Tournaments</a>
  <a href="#">Event Plan</a>
  <a href="#">Register</a>
  <nav>
    <div class="hero-image">
      <div class="hero-text">
        <h1 style="font-size: 50px">Checkmate</h1>
        <p>Chess Tournaments Online</p>
      </div>
    </div>
  </nav>
</nav>


<div class="slideshow-container">
  <div class="mySlides fade">
    <div class="numbertext">1 / 3</div>
    <img
      src="https://cdn.pixabay.com/photo/2021/05/06/10/27/tulips-6233077__480.jpg"
      style="width: 100%"
    />
    <div class="text">Caption Text</div>
  </div>
  <div class="mySlides fade">
    <div class="numbertext">2 / 3</div>
    <img
      src="https://cdn.pixabay.com/photo/2021/05/06/10/27/tulips-6233077__480.jpg"
      style="width: 100%"
    />
    <div class="text">Caption Two</div>
  </div>
  <div class="mySlides fade">
    <div class="numbertext">3 / 3</div>
    <img
      src="https://cdn.pixabay.com/photo/2021/05/06/10/27/tulips-6233077__480.jpg"
      style="width: 100%"
    />
    <div class="text">Caption Three</div>
  </div>
  <a class="prev" onclick="plusSlides(-1)">&#10094;</a>
  <a class="next" onclick="plusSlides(1)">&#10095;</a>
</div>
<br />
<div style="text-align: center">
  <span class="dot" onclick="currentSlide(1)"></span>
  <span class="dot" onclick="currentSlide(2)"></span>
  <span class="dot" onclick="currentSlide(3)"></span>
</div>
<script>
  var slideIndex = 1;
  showSlides(slideIndex);
  function plusSlides(n) {
    showSlides((slideIndex += n));
  }
  function currentSlide(n) {
    showSlides((slideIndex = n));
  }

  function showSlides(n) {
    var i;
    var slides = document.getElementsByClassName("mySlides");
    var dots = document.getElementsByClassName("dot");
    if (n > slides.length) {
      slideIndex = 1;
    }
    if (n < 1) {
      slideIndex = slides.length;
    }
    for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none";
    }
    for (i = 0; i < dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
    }
    slides[slideIndex - 1].style.display = "block";
    dots[slideIndex - 1].className += " active";
  }
</script>
.slideshow容器{
最大宽度:1000px;
位置:固定;
保证金:自动;
z指数:4;
顶部:50px;
}
将死
国际象棋在线比赛

1/3 标题文本 2/3 标题二 3/3 标题三 ❮ ❯
var slideIndex=1; 放映幻灯片(幻灯片索引); 函数加滑块(n){ 放映幻灯片((幻灯片索引+=n)); } 功能当前幻灯片(n){ 放映幻灯片((幻灯片索引=n)); } 功能演示幻灯片(n){ var i; var slides=document.getElementsByClassName(“mySlides”); var dots=document.getElementsByClassName(“dot”); 如果(n>幻灯片长度){ slideIndex=1; } if(n<1){ slideIndex=slides.length; } 对于(i=0;i
我尝试了,但没有成功,结果是一样的。虽然这让我看到了显示的图像,并且它位于导航栏和英雄图像的前面,但现在我的整个页面布局都乱了……我的js按钮也不起作用