Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
4.5 kB
1
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Website</title>
  <script src="/"></script>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <header>
    <div class="header-top">
      <div class="header-logo">
        <img src="logo.png" alt="Logo">
      </div>
      <div class="header-social">
        <a href="#"><img src="иконки/whatsapp.png" alt="Whatsapp"></a>
        <a href="#"><img src="иконки/tg.png" alt="Telegram"></a>
        <a href="#"><img src="иконки/ig.png" alt="Instagram"></a>
      </div>
      <div class="header-contact">
        <p>Phone: 123-456-7890</p>
        <p>Email: info@mywebsite.com</p>
      </div>
    </div>
    <div class="header-line"></div>
  </header>

  <main>
    <div class="slider">
      <div class="slides">
        <div class="slide slide1">
          <img src="фотографии/img1.jpg" alt="Slide 1">
        </div>
        <div class="slide slide2">
          <img src="фотографии/img2.jpg" alt="Slide 2">
        </div>
        <div class="slide slide3">
          <img src="фотографии/img3.jpg" alt="Slide 3">
        </div>
        <div class="slider-buttons">
          <img src="кость.png" class="prev-slide" alt="Previous slide">
          <img src="кость.png" class="next-slide" alt="Next slide">
        </div>
    
  </main>

  <script src="script.js"></script>
</body>
</html>
/* Шапка */

header {
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
}

.header-logo img {
  width: 150px;
  height: 60px;
}

.header-social img {
  width: 40px;
  height: 40px;
  margin-right: 10px;
}

.header-contact p {
  font-size: 14px;
  margin: 0 10px;
}

.header-line {
  height: 1px;
  background-color: #eee;
}

/* Слайдер */

.slider-container .slider-btn {
  z-index: 1;
}

.slider-container .slide img {
  z-index: 0;
}

.slider {
  position: relative;
  width: 100%;
  height: 500px;
  overflow: hidden;
}

.slides {
  display: flex;
  width: 100%;
  height: 100%;
}

.slide {
  flex-shrink: 0;
  width: 100%;
  height: 100%;
  position: relative;
}

.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slide.active {
  z-index: 1;
}

.slide.previous {
  z-index: 0;
  transform: translateX(-100%);
}

.slide.next {
  z-index: 0;
  transform: translateX(100%);
}

.prev,
.next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border: none;
  outline: none;
  cursor: pointer;
}

.prev {
  left: 0;
  z-index: 1;
}

.next {
  right: 0;
  z-index: 1;
}

.prev:hover,
.next:hover {
  background-color: rgba(0, 0, 0, 0.5);
}

.slider-buttons img {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  width: 50px;
  height: 50px;
}

.prev-slide {
  left: 20px;
}

.next-slide {
  right: 20px;
}

.slider-item {
  display: none;
}

.slider-item.active {
  display: block;
}

function showSlide(n) {
  var slides = document.getElementsByClassName("slide");
  var dots = document.getElementsByClassName("dot");
  for (var i = 0; i < slides.length; i++) {
    slides[i].style.display = "none";
  }
  for (var i = 0; i < dots.length; i++) {
    dots[i].className = dots[i].className.replace(" active", "");
  }
  slides[n].style.display = "block";
  dots[n].className += " active";
}

function plusSlides(n) {
  slideIndex += n;
  if (slideIndex > slides.length - 1) {
    slideIndex = 0;
  } else if (slideIndex < 0) {
    slideIndex = slides.length - 1;
  }
  showSlide(slideIndex);
}

function currentSlide(n) {
  slideIndex = n;
  showSlide(slideIndex);
}

var slideIndex = 0;
showSlide(slideIndex);

var prev = document.getElementById("prev");
var next = document.getElementById("next");
prev.addEventListener("click", function() {
  plusSlides(-1);
});
next.addEventListener("click", function() {
  plusSlides(1);
});

var dots = document.getElementsByClassName("dot");
for (var i = 0; i < dots.length; i++) {
  dots[i].addEventListener("click", function() {
    var slide = parseInt