Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Apple Slider</title>
		<link
    rel="stylesheet"
    href="https://use.fontawesome.com/releases/v5.7.2/css/all.css"
    integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr"
    crossorigin="anonymous"
    />
</head>
<body>
	<section id="slideshow">
		    <div class="slider">
        <div class="slide current">
            <div class="content">
                <h1>MacBook</h1>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit illo qui ad repudiandae! Quia, quidem.</p>
            </div>
        </div>
    
        <div class="slide">
            <div class="content">
                <h1>iPhone</h1>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit illo qui ad repudiandae! Quia, quidem.</p>
            </div>
        </div>
    
        <div class="slide">
            <div class="content">
                <h1>iPad</h1>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit illo qui ad repudiandae! Quia, quidem.</p>
            </div>
        </div>
					
				 <div class="slide">
            <div class="content">
                <h1>Apple Watch</h1>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit illo qui ad repudiandae! Quia, quidem.</p>
            </div>
        </div>
					
				 <div class="slide">
            <div class="content">
                <h1>AirPods</h1>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit illo qui ad repudiandae! Quia, quidem.</p>
            </div>
        </div>
    </div>
		
		<div class="onoffswitch">
    	<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
    	<label class="onoffswitch-label" for="myonoffswitch">Auto</label>
		</div>
		
    <div class="buttons">
        <button id="prev"><i class="fas fa-arrow-left"></i></button>
        <button id="next"><i class="fas fa-arrow-right"></i></button>
    </div>
	</section>	
</body>
</html>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Roboto');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background: #333;
    color: #fff;
    line-height: 1.6;
}

.slider{
    position: relative;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
		transform: scale(1.2);
    transition: all 2s ease-in-out;
}

.slide.current {
    opacity: 1;
		transform: scale(1);
}

.slide .content {
    position: absolute;
    bottom: 70px;
    left: -600px;
    opacity: 0;
    width: 600px;
    background-color: rgba(255, 255, 255, 0.8);
    color: #333;
    padding: 35px;
}

.slide .content h1 {
    margin-bottom: 10px;
		color: #E94654;
		font-family: 'Anton';
		font-size: 50px;
		font-weight: 800;
}

.slide.current .content {
    opacity: 1;
    transform: translateX(600px);
    transition: all 1s ease-in-out 1s;
}

.buttons button#next {
    position: absolute;
    top: 50%;
    right: 15px;
}

.buttons button#prev {
    position: absolute;
    top: 50%;
    left: 15px;
}

.buttons button {
    border: 2px solid #E94654;
    background-color: transparent;
    color: #E94654;
    cursor: pointer;
    padding: 13px 15px;
    border-radius: 50%;
    outline: none;
}

.buttons button:hover {
	background-color: #E94654;
	color: #FFF;
}

@media(max-width: 500px) {
	.slide .content {
		bottom: -300px;
		left: 0;
		width: 100%
	}
	
	.slide.current .content {
		transform: translateY(-300px);
	}
}



/* Background Images */
.slide:first-child {
    background: url('https://drive.google.com/uc?id=17tLcBTupNVFBDhqkzdfYq5XqS5MnShPb') no-repeat center center/cover;
}
.slide:nth-child(2) {
    background: url('https://drive.google.com/uc?id=1Oxn2mhUOSG-n2kU_e-PAk-_I6erD4aVt') no-repeat center center/cover;
}
.slide:nth-child(3) {
    background: url('https://drive.google.com/uc?id=1A8ci7uQx4ualinoXVY4BDMwO_YCnzZWK') no-repeat center center/cover ;
}
.slide:nth-child(4) {
    background: url('https://drive.google.com/uc?id=1apx4Jkym-X8XvLvopVWEVtjKvvc9yhWq') no-repeat center center/cover;
}
.slide:nth-child(5) {
    background: url('https://drive.google.com/uc?id=19eTswcHPUVwmVLuqPsUXeKcqsn1hzsQv') no-repeat center center/cover;
}

.onoffswitch {
	position: absolute;
	top: 10%;
	right: 15px;
	width: 75px;
  -webkit-user-select:none; -moz-user-select:none;
	-ms-user-select: none;
}
.onoffswitch-checkbox {
    display: none;
}
.onoffswitch-label {
    display: block; overflow: hidden; cursor: pointer;
    height: 36px; padding: 0; line-height: 36px;
    border: 2px solid #E3E3E3; border-radius: 36px;
    background-color: #FFFFFF;
    transition: background-color 0.3s ease-in;
}
.onoffswitch-label:before {
    content: "";
    display: block; width: 36px; margin: 0px;
    background: #FFFFFF;
    position: absolute; top: 0; bottom: 0;
    right: 37px;
    border: 2px solid #E3E3E3; border-radius: 36px;
    transition: all 0.3s ease-in 0s; 
}
.onoffswitch-checkbox:checked + .onoffswitch-label {
    background-color: #E94654;
}
.onoffswitch-checkbox:checked + .onoffswitch-label, .onoffswitch-checkbox:checked + .onoffswitch-label:before {
   border-color: #E94654;
}
.onoffswitch-checkbox:checked + .onoffswitch-label:before {
    right: 0px; 
}
              
            
!

JS

              
                const slides = document.querySelectorAll('.slide');
const next = document.querySelector('#next');
const prev = document.querySelector('#prev');
const toggle = document.querySelector('#myonoffswitch');
let auto = true; // Auto scroll
const intervalTime = 7000;
let slideInterval;

const nextSlide = () => {
    // Get current class
    const current = document.querySelector('.current');
    // Remove current class
    current.classList.remove('current');
    // Check for next slide
    if (current.nextElementSibling) {
        // Add current to next sibiling
        current.nextElementSibling.classList.add('current');
    }
    else {
        // Add current to start
        slides[0].classList.add('current');
    }
    setTimeout(() => current.classList.remove('current'));
}

const prevSlide = () => {
    // Get current class
    const current = document.querySelector('.current');
    // Remove current class
    current.classList.remove('current');
    // Check for next slide
    if (current.previousElementSibling) {
        // Add current to prev sibiling
        current.previousElementSibling.classList.add('current');
    }
    else {
        // Add current to last
        slides[slides.length - 1].classList.add('current');
    }
    setTimeout(() => current.classList.remove('current'));
}

// Button events
next.addEventListener('click', e => {
    nextSlide();
		if(auto) {
			clearInterval(slideInterval);
			slideInterval = setInterval(nextSlide, intervalTime);
		}
})
prev.addEventListener('click', e => {
    prevSlide();
		clearInterval(slideInterval);
		slideInterval = setInterval(nextSlide, intervalTime);
})

// Auto slide toggle
toggle.addEventListener('click', e => {
    if ( toggle.checked ) {
			auto = true;
			slideInterval = setInterval(nextSlide, intervalTime);
    } else {
			auto = false;
			clearInterval(slideInterval);
    }
})

// Auto slide
if(auto) {
	slideInterval = setInterval(nextSlide, intervalTime);
}
              
            
!
999px

Console