OneCompiler

Slider or some thing



<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Slider</title> <link rel="stylesheet" href="style.css"> </head> <body> <button id="alert" onclick="alert()">Alert</button> <a id="alert2" href="../index2.html">New Web page</a> <div id="top" class="top-coming animate"> <h4>Every button need to click 2 time</h4> <button onclick="topHide()">OK</button> </div> <div id="all" class="all"> <div class="maueBar"> <button onclick="hide()"> <div></div> <div></div> <div></div> </button> </div> <div id="bar" class="hide-manue animate"> <h3 class="previus" onclick="hadingCont('h1')">Heading-1</h3> <p class="animate Text" id="h1Text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo, enim.</p>
        <h3 class="previus" onclick="hadingCont('h2')">Heading-2</h3>
        <p class="animate Text" id="h2Text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo, enim.</p>

        <h3 class="previus" onclick="hadingCont('h3')">Heading-3</h3>
        <p class="animate Text" id="h3Text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo, enim.</p>

        <h3 class="previus" onclick="hadingCont('h4')">Heading-4</h3>
        <p class="animate Text" id="h4Text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo, enim.</p>

        <h3 class="previus" onclick="hadingCont('h5')">Heading-5</h3>
        <p class="animate Text" id="h5Text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo, enim.</p>

    </div>
    <div class="total-Slider">
        <!-- slider -->
        <h1 class="h1-style">1.Making slider use vanila javaScript</h1>

        <!-- <button onclick="preFun(1)" class="next">Next</button> -->
        <div id="slider" class="slider">
            <img id="img1" src="" alt="">
        </div>
    </div>
    <!-- <button onclick="sliderLoad('pre')" class="previus">Previus</button> -->
    <div id="dot">
        <div class="dot1"></div>
        <div class="dot1"></div>
        <div class="dot1"></div>
    </div>
    <!-- slider -->

</div>

<script src="coustom.js"></script>
</body> </html>

------------------style
body {
padding: 0;
margin: 0;
}

.h1-style {
text-align: center;
font-style: initial;
text-shadow: 1px 3px 3px gray;
background-color: azure;
border: 2px solid gainsboro;
border-radius: 5px;
color: rgb(67, 62, 62);
margin: 10px 0 45px 0;
box-shadow: 1.5px 3px 2px gray;
cursor: pointer;
}

.h1-style:hover {
box-shadow: 2.5px 4px 3px gray;
background-color: rgb(219, 251, 251);
transition: .8s;
color: rgb(63, 44, 44);
}

.slider #img1 {
width: 100%;
height: 100%;
animation-name: example;
}

.slider {
background: red;
width: 800px;
height: 650px;
border: 5px solid rgb(231, 236, 231);
border-radius: 10px;
margin: auto;
}

.dot1 {
width: 8px;
height: 6px;
border-radius: 50%;
padding: 5px 5px;
border: 3px solid rgb(174, 255, 0);
margin: 8px 6px;
}

#dot1-active {
background-color: red;
transition: .5s;
}

#dot {
display: flex;
justify-content: center;
transition: 1s;
}

/* .next {
float: right;
margin-top: 230px;
margin-right: 300px;
border: 4px solid cyan;
border-radius: 5px;
padding: 4px 5px;
background: lightblue;
color: blue;
}

.next:hover {
border: 4px solid lightblue;
background: cyan;
color: rgb(59, 59, 166);
transition: .5s;
} */

.previus {
float: left;
/* margin-top: -320px; /
/
margin-left: 230px; */
border: 4px solid cyan;
border-radius: 5px;
padding: 4px 5px;
background: lightblue;
color: blue;
width: 70%;
}

.previus:hover {
border: 4px solid lightblue;
background: cyan;
color: rgb(59, 59, 166);
transition: .5s;
}

.total-Slider {
position: relative;
}

/* end slider */

.maueBar {
margin: 20px;
}

.maueBar div {
width: 35px;
height: 4px;
background-color: aqua;
margin: 5px 0;
}

.maueBar button {
border: 3px solid cyan;
background-color: aliceblue;
cursor: pointer;
}

.maueBar button:hover {
border: 3px solid rgb(103, 163, 215);
background-color: rgba(18, 196, 196, 0.711);
transition: .6s;
}

.hide-manue {
width: 250px;
height: 600px;
background-color: rgb(0, 0, 0, .5);
border: 5px solid rgb(0, 0, 0, .6);
border-radius: 5px;
box-shadow: 3px 3px 3px black;
z-index: 100;
position: absolute;
margin-top: -13px;
/* display: none; */
}

.hide-manue h3 {
color: wheat;
margin: 15px;
cursor: pointer;
}

.Text {
padding-top: 5px;
display: none;
margin: 5px 5px;
color: aliceblue;
}

.animate {
animation: animatetop 0.4s
}

@keyframes animatetop {
from {
opacity: 0
}
to {
opacity: 1
}
}

.top-coming {
width: 400px;
height: 200px;
background-color: #fff;
border: 3px dotted darkolivegreen;
position: absolute;
z-index: 150;
top: 0;
margin-left: 400px;
display: none;
}

.top-coming h4 {
text-align: center;
margin-top: 80px;
}

.top-coming button {
float: right;
margin-right: 40px;
margin-top: 40px;
padding: 5px 16px;
border: 3px solid gray;
}

#alert {
float: right;
position: fixed;
right: 20px;
z-index: 10000;
}

#alert2 {
float: right;
position: fixed;
right: 20px;
z-index: 10000;
top: 50px;
}
----------------script
'use strict';
// slider thing
let a = 0;
let time = 3000;
let image = [];
// all image
image[0] = '1photosec3.png';
image[1] = '2photosec3.png';
image[2] = '3photosec3.png';
window.onload = sliderLoad();

function sliderLoad() {
// image
let dotGet = document.getElementById('dot');
let imgId = document.getElementById('img1');
imgId.src = image[a];
// // dot
dotGet.innerHTML = <div onclick='dot1()' class="dot1"></div> <div class="dot1"></div> <div class="dot1"></div>;
dotGet.children[a].id = 'dot1-active';

if (a < image.length - 1) {
    a++;
} else {
    a = 0;
}
setTimeout('sliderLoad(a)', time);

}

// manu bar hider
const bar = document.getElementById('bar');
bar.style.display = 'none'

function hide() {
if (bar.style.display === 'none') {
bar.style.display = 'block';
} else {
bar.style.display = 'none';
}

}
let allbody = document.getElementById('all');

function alert() {
document.getElementById('top').style.display = 'block';
document.body.style.backgroundColor = "gray";

allbody.style.display = 'none';

}
// hiden manu content
function hadingCont(h) {
let ho = document.getElementById(${h}Text);
if (ho.style.display == 'none') {
ho.style.display = 'none';
} else {
ho.style.display = 'block';
}
}
// let topH = document.querySelector('.topHide').addEventListener = ('click', topHide);

function topHide() {
allbody.style.display = 'block';
const top = document.getElementById('top').style.display = 'none';
document.body.style.backgroundColor = "white";
}