Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

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.

HTML

              
                <div class="card">
 <div class="card__tip">
  <span>Click the Arrows</span>
 </div>
 <div class="card__arrows">
  <i class="card__arrow-before fas fa-angle-double-left" id="before"></i>
  <i class="card__arrow-next fas fa-angle-double-right" id="next"></i>
 </div> 
 <div class="card__container">
  <div class="card__image">  
   <img src="https://image.ibb.co/cER46d/1.jpg" id="image" alt="Image">
  </div> 
  <div>
   <p class="card__text card__title" id="title">Is The Product Safe?</p>
  </div>
  <div>
   <p class="card__text card__description" id="description">It's so protected that even our team has no any access to your payment data</p>
  </div>  
 </div> 
 <div class="card__dots">
   <div class="card__dot card__dot--active"></div>
   <div class="card__dot"></div>
   <div class="card__dot"></div>
  </div>
</div>
              
            
!

CSS

              
                // Variables
$color1: #b3c0ca;
$color2: #597694;

// Mixin
@mixin card {
 background-color: #fff;
 border: 1px solid #f2f4f7;
 border-radius: 15px;
 box-shadow: 4px 9px 28px -1px #ccc;
}

body {
 background: linear-gradient(#a5dacd 0, #a5dacd 50%, #fff 50.1%, #fff 100%) no-repeat;
 display: flex;   
 height: 100vh;
}
.card {
 @include card; 
 width: 325px;
 height: 500px; 
 margin: auto;
 position: relative;
}
.card__tip { 
 position: absolute;
 right: -100px;
 transform: rotate(20deg);
 
 span {  
  color: $color2;
  font-family: 'Waiting for the Sunrise', cursive;
  font-size: 28px;
 }
}
.card__container { 
 margin: 0 50px;
}
.card,
.card__container {
 display: flex;
 flex-flow: column;
 text-align: center;
  transition: opacity .2s linear;
 opacity: 1;
}
.card__arrows {
 display: flex;
 justify-content: space-between;
 margin: 20px 30px;
 i {
  color: $color1;
  cursor: pointer;
  font-size: 20px;
 }
}
.card__arrow-before {
 visibility: hidden;
}
.card__image {
 margin-top: 30px;
 img {
  width: 70%;
  max-height: 158px;
 }
}
.card__text {
 font-family: 'Ubuntu Mono', monospace;
}
.card__title {
 color: $color2;
 font-size: 22px;
 font-weight: 700; 
 margin-top: 30px;
}
.card__description {
 color: $color1;
 font-size: 18px;
 min-height: 80px;
}
.card__dots {
 align-self: center;
 display: flex;
 justify-content: space-between;
 margin-top: 20px;
 width: 70px;
}
.card__dot {
 width: 10px;
 height: 10px;
 border-radius: 50%;
 background-color: $color1;
 cursor: pointer;
}
.card__dot--active {
 background-color: $color2;
}

              
            
!

JS

              
                var cont = 0; // Counter

//Card arrows
const nextCard = document.querySelector('#next');
const beforeCard = document.querySelector('#before');

const container = document.querySelector('.card__container');
const dots = document.querySelectorAll('.card__dot');
const tip = document.querySelector('.card__tip');

// Card content
const image = document.querySelector('#image');
const title = document.querySelector('#title');
const description = document.querySelector('#description');

// Just to simulate some data coming from API
const products = {
  "items": [
   {
    "image": "https://image.ibb.co/cER46d/1.jpg",
    "title": "Is The Product Safe?",
    "description": "It's so protected that even our team has no any access to your payment data"
   },
   {
    "image": "https://image.ibb.co/e9PDzy/2.jpg",
    "title": "Do You Bill My Card?",
    "description": "We will never bill your card, we just earn some lorem ipsum whatever you like"
   },
   {
    "image": "https://image.ibb.co/icyvCJ/3.jpg",
    "title": "Tell Me About Data?",
    "description": "You provided your data, so now...doesn't matter!! We need call the cops  =x"
   }
  ]
}

// Events
nextCard.addEventListener('click', () => {
 incrementCounter(); 
 updateProduct();
 updateDots();
 hideTip();
});

beforeCard.addEventListener('click', () => {
 decrementCounter();
 updateProduct();
 updateDots();
});

// Functions
function visibilityBeforeArrow(prop) {
 beforeCard.style.visibility = prop;
}

function visibilityNextArrow(prop) {
 nextCard.style.visibility = prop;
}

function incrementCounter() {
 cont++;
 if (cont >=0 && cont < products.items.length - 1) {
  visibilityBeforeArrow('visible');
  visibilityNextArrow('visible');
  return;
 }
 if (cont >= products.items.length - 1) {  
  visibilityBeforeArrow('visible');
  visibilityNextArrow('hidden');
  cont = products.items.length - 1;
  return;
 }  
}

function decrementCounter() {
 cont--;
 if (cont == 0) {
  visibilityBeforeArrow('hidden');
  return;
 }
 if (cont > 0 && cont < products.items.length - 1) {
  visibilityNextArrow('visible');
  return;
 }
}

function updateProduct() {
 image.src = products.items[cont].image;
 title.textContent = products.items[cont].title;
 description.textContent = products.items[cont].description;
}

function updateDots() { 
 dots.forEach((dot) => {
  dot.classList.remove('card__dot--active');
 });
 dots[cont].classList.add('card__dot--active');
}

function hideTip() {
 tip.style.display = 'none';
}
              
            
!
999px

Console