Почему между двумя моими слайд-шоу огромное пространство? - PullRequest
2 голосов
/ 07 марта 2020

Я не добавил br между этими двумя слайд-шоу, так почему между ними огромное пространство (размером в 7 разрывов строк)?

Все, что я знаю, это basi c html и css (которые я выучил самостоятельно). Я ничего не знаю о Javascript ВСЕ. Код Javascript, который я имею ниже, взят из w3schools, которые нам показал мой учитель.

function openNav() {
  document.getElementById("mySidebar").style.width = "250px";
  document.getElementById("main").style.marginLeft = "250px";
}

function closeNav() {
  document.getElementById("mySidebar").style.width = "0";
  document.getElementById("main").style.marginLeft = "0";
}

var slideIndex = [1, 1];
var slideId = ["mySlides1", "mySlides2"]
showSlides(1, 0);
showSlides(1, 1);

function plusSlides(n, no) {
  showSlides(slideIndex[no] += n, no);
}

function showSlides(n, no) {
  var i;
  var x = document.getElementsByClassName(slideId[no]);
  if (n > x.length) {
    slideIndex[no] = 1
  }
  if (n < 1) {
    slideIndex[no] = x.length
  }
  for (i = 0; i < x.length; i++) {
    x[i].style.display = "none";
  }
  x[slideIndex[no] - 1].style.display = "block";
}
/* B O D Y */

body {
  font-family: "Lato", sans-serif;
  background-image: url(stars.gif);
  margin: 0;
}

#content {
  background-color: rgba(255, 255, 255, 0.2);
  margin-left: 200px;
  margin-right: 200px;
  padding-top: 15px;
  padding-bottom: 15px;
}


/* S I D E B A R */

.sidebar {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 1;
  top: 0;
  left: 0;
  background-color: #111;
  overflow-x: hidden;
  transition: 0.5s;
  padding-top: 60px;
}

.sidebar a {
  padding: 8px 8px 8px 32px;
  text-decoration: none;
  font-size: 25px;
  color: #818181;
  display: block;
  transition: 0.3s;
}

.sidebar a:hover {
  color: #f1f1f1;
}

.sidebar .closebtn {
  position: absolute;
  top: 0;
  right: 25px;
  font-size: 36px;
  margin-left: 50px;
}

.openbtn {
  font-size: 20px;
  cursor: pointer;
  background-color: #111;
  color: white;
  padding: 10px 15px;
  border: none;
}

.openbtn:hover {
  background-color: #444;
}

#main {
  transition: margin-left .5s;
  padding: 16px;
}


/* On smaller screens, where height is less than 450px, change the style of the sidenav (less padding and a smaller font size) */

@media screen and (max-height: 450px) {
  .sidebar {
    padding-top: 15px;
  }
  .sidebar a {
    font-size: 18px;
  }
}


/* A B O U T  T H E  A U T H O R */

#about-the-author-heading {
  text-align: center;
  margin-left: 200px;
  margin-right: 200px;
  padding-top: 5px;
  padding-bottom: 5px;
  border-top: 1px solid rgb(188, 184, 184);
  border-bottom: 1px solid rgb(188, 184, 184);
  color: white;
}

#about-the-author-description {
  text-align: justify;
  margin-left: 200px;
  margin-right: 200px;
  font-size: 24px;
}

#about-the-author-image {
  width: 200px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

#about-the-author-description {
  color: white;
}


/* S L I D E S H O W */

* {
  box-sizing: border-box
}

.mySlides1,
.mySlides2 {
  display: none text-align: center;
  height: 600px;
}

img {
  vertical-align: middle;
}

.mySlides1 img,
.mySlides2 img {
  width: 100%;
  max-height: 100%;
  object-fit: contain;
}


/* Slideshow container */

.slideshow-container {
  max-width: 600px;
  position: relative;
  margin: auto;
}


/* Next & previous buttons */

.prev,
.next {
  cursor: pointer;
  position: absolute;
  top: 33%;
  width: auto;
  padding: 16px;
  margin-top: -22px;
  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);
}


/* 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
  }
}

.slideshow-title {
  color: white;
  text-align: center;
}


/* 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;
}
image

1 Ответ

0 голосов
/ 07 марта 2020

Это потому, что между вашими слайд-шоу есть текст! Весь ваш текст белый на белом фоне, поэтому вы не видите ни одного слова. Выделите это пустое место, и вы найдете слово Jeyen :>. Чтобы увидеть весь текст на своей странице, измените .content 'background-color на что-то вроде lightgray.

Удалите строку <h1 class = "slideshow-title">Jeyen :></h1>, и пространство между слайд-шоу исчезнет.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...