Scrolling Card UI With Flexbox

Jyotishgher Astrology
By -
0

 Scrolling Card UI With Flexbox




<!DOCTYPE html>

<html>

<head>

<style>

div.gallery {

  margin: 5px;

  border: 1px solid #ccc;

  float: left;

  width: 180px;

}


div.gallery:hover {

  border: 1px solid #777;

}


div.gallery img {

  width: 100%;

  height: auto;

}


div.desc {

  padding: 15px;

  text-align: center;

}


.row{

  align-items: stretch;

  display: flex;

  flex-direction: row;

  flex-wrap: nowrap;

  overflow-x: auto;

  overflow-y: hidden;

}

.card {

  /*float: left;*/

  max-width: 33.333%;

  padding: .25rem;

  margin-bottom: 2rem;

  border: 0;

  flex-basis: 33.333%;

  flex-grow: 0;

  flex-shrink: 0;

}

.card > img {

  margin-bottom: .75rem;

  width: 100%;

}

.card-text {

  font-size: 85%;

}




:root {

  --red: #ef233c;

  --darkred: #c00424;

  --platinum: #e5e5e5;

  --black: #2b2d42;

  --white: #fff;

  --thumb: #edf2f4;

}


* {

  box-sizing: border-box;

  padding: 0;

  margin: 0;

}


body {

  font: 16px / 24px "Rubik", sans-serif;

  color: var(--black);

  background: var(--platinum);

  margin: 50px 0;

}


.container {

  max-width: 1400px;

  padding: 0 15px;

  margin: 0 auto;

}


h2 {

  font-size: 32px;

  margin-bottom: 1em;

}


.cards {

  display: flex;

  padding: 25px 0px;

  list-style: none;

  overflow-x: scroll;

  scroll-snap-type: x mandatory;

}


.card {

  display: flex;

  flex-direction: column;

  flex: 0 0 100%;

  padding: 20px;

  background: var(--white);

  border-radius: 12px;

  box-shadow: 0 5px 15px rgba(0, 0, 0, 15%);

  scroll-snap-align: start;

  transition: all 0.2s;

}


.card:not(:last-child) {

  margin-right: 10px;

}


.card:hover {

  color: var(--white);

  background: var(--red);

}


.card .card-title {

  font-size: 20px;

}


.card .card-content {

  margin: 20px 0;

  max-width: 85%;

}


.card .card-link-wrapper {

  margin-top: auto;

}


.card .card-link {

  display: inline-block;

  text-decoration: none;

  color: white;

  background: var(--red);

  padding: 6px 12px;

  border-radius: 8px;

  transition: background 0.2s;

}


.card:hover .card-link {

  background: var(--darkred);

}


.cards::-webkit-scrollbar {

  height: 12px;

}


.cards::-webkit-scrollbar-thumb,

.cards::-webkit-scrollbar-track {

  border-radius: 80px;

}


.cards::-webkit-scrollbar-thumb {

  background: var(--darkred);

}


.cards::-webkit-scrollbar-track {

  background: var(--thumb);

}


@media (min-width: 250px) {

  .card {

    flex-basis: calc(50% - 10px);

  }


  .card:not(:last-child) {

    margin-right: 20px;

  }

}


@media (min-width: 400px) {

  .card {

    flex-basis: calc(calc(100% / 3) - 20px);

  }


  .card:not(:last-child) {

    margin-right: 30px;

  }

}


@media (min-width: 1100px) {

  .card {

    flex-basis: calc(25% - 30px);

  }


  .card:not(:last-child) {

    margin-right: 40px;

  }

}



/* FOOTER STYLES

–––––––––––––––––––––––––––––––––––––––––––––––––– */

.page-footer {

  position: fixed;

  right: 0;

  bottom: 20px;

  display: flex;

  align-items: center;

  padding: 5px;

  z-index: 1;

}


.page-footer a {

  display: flex;

  margin-left: 4px;

}





</style>

</head>

<body>





<div class="container">

  <h2>Scrolling Card UI With Flexbox</h2>

  <ul class="cards">

    <li class="card">

      <div>

        <h3 class="card-title">Service 1</h3>

        <div class="card-content">

          <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.</p>

        </div>

      </div>

      <div class="card-link-wrapper">

        <a href="" class="card-link">Learn More</a>

      </div>

    </li>

    <li class="card">

      <div>

        <h3 class="card-title">Service 2</h3>

        <div class="card-content">

          <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ab repudiandae magnam harum natus fuga et repellat in maiores.</p>

        </div>

      </div>

      <div class="card-link-wrapper">

        <a href="" class="card-link">Learn More</a>

      </div>

    </li>

    <li class="card">

      <div>

        <h3 class="card-title">Service 3</h3>

        <div class="card-content">

          <p>Phasellus ultrices lorem vel bibendum ultricies. In hendrerit nulla a ante dapibus pulvinar eu eget quam.</p>

        </div>

      </div>

      <div class="card-link-wrapper">

        <a href="" class="card-link">Learn More</a>

      </div>

    </li>

  


  


 

  </ul>

</div>





<div class="container">

  <div class="row">

    <div class="card">

      <img src="https://picsum.photos/300/200">

      <p class="card-text"> wider card</p>

    </div>

    <div class="card">

      <img src="https://picsum.photos/300/200">

      <p class="card-text">This is a wider card </p>

    </div>

     <div class="card">

      <img src="https://picsum.photos/300/200">

      <p class="card-text">This is a wider card</p>

    </div>

 

  </div>

</div>




</body>

</html>



Post a Comment

0Comments

Post a Comment (0)