Pen Settings



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


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


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.


Save Automatically?

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.


                <link href="[email protected]&display=swap" rel="stylesheet">

<div class="wrapper">
  <h2>Image Slider (Javascript)</h2>
  <div class="slider">
  <img src="" alt="Strawberry" />

 <img src="" alt="Dock" />
 <img src="" alt="Bee" />
<img src="" alt="Bear" />
 <img src="" alt="Squirrel" />
<img src="" alt="Trees" />
    <img src="" alt="Trees" />
      <img src="" alt="Trees" />

  <span class="control-slider flex items-center justify-center btn-left">
	  <span class="control-slider flex items-center justify-center btn-right">
  <p style="text-align:center">
  <span>Created by</span>
  <a href="">
    Taimoor Sattar


  font-family: 'Roboto', sans-serif;

    margin: auto;
    max-width: 960px;
    position: relative;

  width: 100%;
  transition: all 0.5s linear;
  white-space: nowrap;

.slider img{
  display: inline-block;
  height: 200px

.control-slider {
    cursor: pointer;
    position: absolute;
    z-index: 5;
    top: 50%;
    border-radius: 50%;
    height: 40px;
    width: 40px;
    background-color: #fff;
    line-height: 40px;
    color: #333;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  user-select: none;

.btn-left {
  text-align: center;
  left: 10px;

.btn-right {
  text-align: center;
  right: 10px;

::-webkit-scrollbar {
  height: 5px;
  width: 10px;
  border-radius: 5px;

/* Track */
::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 5px;

/* Handle */
::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 5px;

/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
  background: #555;


                const sliderElm = document.querySelector(".slider");

const btnLeft = document.querySelector(".btn-left");
const btnRight = document.querySelector(".btn-right");

const numberSliderBoxs = sliderElm.children.length;
const widthSliderBoxs = sliderElm.children[0].clientWidth
let totalsize = numberSliderBoxs * widthSliderBoxs;

function moveLeft() {
    top: 0,
    left: -widthSliderBoxs,
    behavior : "smooth"

function moveRight() {
    top: 0,
    left: widthSliderBoxs,
    behavior : "smooth"

// Event Listeners:
btnLeft.addEventListener("click", moveLeft);
btnRight.addEventListener("click", moveRight);