skip to Main Content

I tried so much but I can’t fix the overflow and just center the flipcards. I also have a url to the dummy website

Can someone please help me? I don’t know what to do

        <!-- flip-card-container -->
        <div class="index-cards-container text-center">    
            <div class="index-cards grid-3">
                <div class="flip-card-container" style="--hue: 220">
                    <div class="flip-card">
                
                    <div class="card-front">
                        <div class="card-content">
                        <div class="img-bg"></div>
                        <img src="img/velg-2.jpg" alt="Brohm Lake">
                        <p class="card-text">Interieurreiniging </p>
                        </div>
                
                        <ul>
                        <li>Detail 1</li>
                        <li>Detail 2</li>
                        <li>Detail 3</li>
                        <li>Detail 4</li>
                        <li>Detail 5</li>
                        </ul>
                    </div>
                
                    <div class="card-back">
                        <div class="card-content">
                        <div class="img-bg"></div>
                        <img src="img/polijsten-4.jpg" alt="Brohm Lake">
                        </div>
                
                        <a href= "interieurreiniging.html" class="btn"><span></span>Meer informatie</a>
                
                        <div class="design-container">
                        <span class="design design--1"></span>
                        <span class="design design--2"></span>
                        <span class="design design--3"></span>
                        <span class="design design--4"></span>
                        <span class="design design--5"></span>
                        <span class="design design--6"></span>
                        <span class="design design--7"></span>
                        <span class="design design--8"></span>
                        </div>
                    </div>
                
                    </div>
                </div>
                <!-- /flip-card-container -->
                
                <!-- flip-card-container -->
                <div class="flip-card-container" style="--hue: 170">
                    <div class="flip-card">
                
                    <div class="card-front">
                        <div class="card-content">
                            <div class="img-bg"></div>
                            <img src="img/polijsten-3.jpg" alt="Image 2">
                            <p class="card-text">Exterieurreiniging</p>
                        </div>
                
                        <ul>
                        <li>Detail 1</li>
                        <li>Detail 2</li>
                        <li>Detail 3</li>
                        <li>Detail 4</li>
                        <li>Detail 5</li>
                        </ul>
                    </div>
                
                    <div class="card-back">
                        <div class="card-content">
                        <div class="img-bg"></div>
                        <img src="img/matten.jpg" alt="image-2">
                        </div>
                
                        <a href= "exterieurreiniging.html" class="btn"><span></span>Meer informatie</a>
                
                        <div class="design-container">
                        <span class="design design--1"></span>
                        <span class="design design--2"></span>
                        <span class="design design--3"></span>
                        <span class="design design--4"></span>
                        <span class="design design--5"></span>
                        <span class="design design--6"></span>
                        <span class="design design--7"></span>
                        <span class="design design--8"></span>
                        </div>
                    </div>
                
                    </div>
                </div>
                <!-- /flip-card-container -->
                
                <!-- flip-card-container -->
                <div class="flip-card-container" style="--hue: 350">
                    <div class="flip-card">
                
                    <div class="card-front">
                        <div class="card-content">
                        <div class="img-bg"></div>
                        <img src="img/polijsten.jpg" alt="Brohm Lake">
                        <p class="card-text">Volledige reiniging</p>
                        </div>
                
                        <ul>
                        <li>Detail 1</li>
                        <li>Detail 2</li>
                        <li>Detail 3</li>
                        <li>Detail 4</li>
                        <li>Detail 5</li>
                        </ul>
                    </div>
                
                    <div class="card-back">
                        <!-- only if the image is necessary -->
                        <div class="card-content">
                        <div class="img-bg"></div>
                        <img src="img/poetsen.jpg" alt="Brohm Lake">
                        </div>
                
                        <a href= "volledige-reiniging.html" class="btn"><span></span>Meer informatie</a>
                
                        <!-- can add svg here and remove these eight spans -->
                        <div class="design-container">
                        <span class="design design--1"></span>
                        <span class="design design--2"></span>
                        <span class="design design--3"></span>
                        <span class="design design--4"></span>
                        <span class="design design--5"></span>
                        <span class="design design--6"></span>
                        <span class="design design--7"></span>
                        <span class="design design--8"></span>
                        </div>
                    </div>
                
                    </div>
                </div>
            </div>
    
            <div class="index-cards grid-3">
                <div class="flip-card-container" style="--hue: 220">
                    <div class="flip-card">
                
                    <div class="card-front">
                        <div class="card-content">
                        <div class="img-bg"></div>
                        <img src="img/velg-2.jpg" alt="Brohm Lake">
                        <p class="card-text">Glas- en <br> ceramische coating</p>
                        </div>
                
                        <ul>
                        <li>Detail 1</li>
                        <li>Detail 2</li>
                        <li>Detail 3</li>
                        <li>Detail 4</li>
                        <li>Detail 5</li>
                        </ul>
                    </div>
                
                    <div class="card-back">
                        <div class="card-content">
                        <div class="img-bg"></div>
                        <img src="img/polijsten-4.jpg" alt="Brohm Lake">
                        </div>
                
                        <a href= "ceramische-coating.html" class="btn"><span></span>Meer informatie</a>
                
                        <div class="design-container">
                        <span class="design design--1"></span>
                        <span class="design design--2"></span>
                        <span class="design design--3"></span>
                        <span class="design design--4"></span>
                        <span class="design design--5"></span>
                        <span class="design design--6"></span>
                        <span class="design design--7"></span>
                        <span class="design design--8"></span>
                        </div>
                    </div>
                
                    </div>
                </div>
                <!-- /flip-card-container -->
                
                <!-- flip-card-container -->
                <div class="flip-card-container" style="--hue: 170">
                    <div class="flip-card">
                
                    <div class="card-front">
                        <div class="card-content">
                            <div class="img-bg"></div>
                            <img src="img/polijsten-3.jpg" alt="Image 2">
                            <p class="card-text">Velg en koplamp<br> reparatie</p>
                        </div>
                
                        <ul>
                        <li>Detail 1</li>
                        <li>Detail 2</li>
                        <li>Detail 3</li>
                        <li>Detail 4</li>
                        <li>Detail 5</li>
                        </ul>
                    </div>
                
                    <div class="card-back">
                        <div class="card-content">
                        <div class="img-bg"></div>
                        <img src="img/matten.jpg" alt="image-2">
                        </div>
                
                        <a href= "reparatie.html" class="btn"><span></span>Meer informatie</a>
                
                        <div class="design-container">
                        <span class="design design--1"></span>
                        <span class="design design--2"></span>
                        <span class="design design--3"></span>
                        <span class="design design--4"></span>
                        <span class="design design--5"></span>
                        <span class="design design--6"></span>
                        <span class="design design--7"></span>
                        <span class="design design--8"></span>
                        </div>
                    </div>
                
                    </div>
                </div>
                <!-- /flip-card-container -->
                
                <!-- flip-card-container -->
                <div class="flip-card-container" style="--hue: 350">
                    <div class="flip-card">
                
                    <div class="card-front">
                        <div class="card-content">
                        <div class="img-bg"></div>
                        <img src="img/polijsten.jpg" alt="Brohm Lake">
                        <p class="card-text">Schadeherstel, uitdeuken<br> en restylen</p>
                        </div>
                
                        <ul>
                        <li>Detail 1</li>
                        <li>Detail 2</li>
                        <li>Detail 3</li>
                        <li>Detail 4</li>
                        <li>Detail 5</li>
                        </ul>
                    </div>
                
                    <div class="card-back">
                        <!-- only if the image is necessary -->
                        <div class="card-content">
                        <div class="img-bg"></div>
                        <img src="img/poetsen.jpg" alt="Brohm Lake">
                        </div>
                
                        <a href= "schadeherstel.html" class="btn"><span></span>Meer informatie</a>
                
                        <!-- can add svg here and remove these eight spans -->
                        <div class="design-container">
                        <span class="design design--1"></span>
                        <span class="design design--2"></span>
                        <span class="design design--3"></span>
                        <span class="design design--4"></span>
                        <span class="design design--5"></span>
                        <span class="design design--6"></span>
                        <span class="design design--7"></span>
                        <span class="design design--8"></span>
                        </div>
                    </div>
                
                    </div>
                </div>
            </div>
        </div>
        <!-- /flip-card-container -->


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

/* .flip-card-container */
.flip-card-container {
  --hue: 150;
  --primary: #9740c9;
  --white-1: hsl(0, 0%, 90%);
  --white-2: hsl(0, 0%, 80%);
  --dark: hsl(var(--hue), 25%, 10%);
  --grey: hsl(0, 0%, 50%);

  width: 310px;
  height: 400px;
  margin: 40px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;

  /* perspective: 1000px; */
}

/* .flip-card */
.flip-card {
  width: inherit;
  height: inherit;

  position: relative;
  transform-style: preserve-3d;
  transition: .6s .1s;
}


/* hover and focus-within states */
.flip-card-container:hover .flip-card,
.flip-card-container:focus-within .flip-card {
  transform: rotateY(180deg);
}

/* .card-... */
.card-front,
.card-back {
  width: 100%;
  height: 100%;
  border-radius: 24px;

  background: var(--dark);
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;

  backface-visibility: hidden;

  display: flex;
  justify-content: center;
  align-items: center;
}

/* .card-front */
.card-front {
  transform: rotateY(0deg);
  z-index: 2;
}

/* .card-back */
.card-back {
  transform: rotateY(180deg);
  z-index: 1;
}

/* card-content */
.card-content {
  z-index: -1;
}

/* card-content, .img-bg */
.card-content,
.img-bg {
  position: absolute;
  top: 0;
  left: 0;

  width: 100%;
  height: 100%;
}

/* img */
.flip-card img {
  height: 100%;
  border-radius: 24px;
  filter: blur(5px);
  
}
/* card-text */
.card-text {
  display: block;

  width: auto;
  margin-top: 12%;
  padding: 8px 22px;

  font-weight: bold;
  line-height: 1.6;
  letter-spacing: 2px;
  word-spacing: 6px;
  text-align: right;

  position: absolute;
  top: 0;
  right: 12px;

  color: var(--white-1);
  background: hsla(var(--hue), 25%, 10%, .5);
}

/* .img-bg */
.img-bg {
  background: hsla(var(--hue), 25%, 10%, .5);
}

.card-front .img-bg {
  clip-path: polygon(0 20%, 100% 40%, 100% 100%, 0 100%);
}

.card-front .img-bg::before {
  content: "";

  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(18deg);

  width: 100%;
  height: 6px;
  border: 1px solid var(--primary);
  border-left-color: transparent;
  border-right-color: transparent;

  transition: .1s;
}

.card-back .img-bg {
  clip-path: polygon(0 0, 100% 0, 100% 80%, 0 60%);
}

/* hover state */
.flip-card-container:hover .card-front .img-bg::before {
  width: 6px;
  border-left-color: var(--primary);
  border-right-color: var(--primary);
}

/* flipcard ul */
.flip-card ul {
  padding-top: 40%;
  margin: 0 auto;
  width: 70%;
  height: 100%;

  list-style: none;
  color: var(--white-1);

  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

/* flip-card li */
.flip-card li {
  width: 100%;
  margin-top: 12px;
  padding-bottom: 12px;

  font-size: 14px;
  text-align: center;

  position: relative;
}

.flip-card li:nth-child(2n) {
  color: var(--white-2);
}

.flip-card li:not(:last-child)::after {
  content: "";

  position: absolute;
  bottom: 0;
  left: 0;

  width: 100%;
  height: 1px;

  background: currentColor;
  opacity: .2;
}

/* button */
.flip-card button {
  font-family: inherit;
  font-weight: bold;
  color: var(--white-1);

  letter-spacing: 2px;

  padding: 9px 20px;
  border: 1px solid var(--grey);
  border-radius: 1000px;
  background: transparent;
  transition: .3s;

  cursor: pointer;
}

.flip-card button:hover,
.flip-card button:focus {
  color: var(--primary);
  background: hsla(var(--hue), 25%, 10%, .2);
  border-color: currentColor;
}

.flip-card button:active {
  transform: translate(2px);
}

/* smaller button */
.flip-card .btn {
    transform: scale(0.9);
}
/* .design-container */
.design-container {
  --tr: 90;
  --op: .5;

  width: 100%;
  height: 100%;

  background: transparent;
  position: absolute;
  top: 0;
  left: 0;

  pointer-events: none;
}

/* .design */
.design {
  display: block;

  background: var(--grey);
  position: absolute;

  opacity: var(--op);
  transition: .3s;
}

.design--1,
.design--2,
.design--3,
.design--4 {
  width: 1px;
  height: 100%;
}

.design--1,
.design--2 {
  top: 0;
  transform: translateY(calc((var(--tr) - (var(--tr) * 2)) * 1%))
}

.design--1 {
  left: 20%;
}

.design--2 {
  left: 80%;
}

.design--3,
.design--4 {
  bottom: 0;
  transform: translateY(calc((var(--tr) + (var(--tr) - var(--tr))) * 1%))
}

.design--3 {
  left: 24%;
}

.design--4 {
  left: 76%;
}

.design--5,
.design--6,
.design--7,
.design--8 {
  width: 100%;
  height: 1px;
}

.design--5,
.design--6 {
  left: 0;
  transform: translateX(calc((var(--tr) - (var(--tr) * 2)) * 1%));
}

.design--5 {
  top: 41%;
}

.design--6 {
  top: 59%;
}

.design--7,
.design--8 {
  right: 0;
  transform: translateX(calc((var(--tr) + (var(--tr) - var(--tr))) * 1%))
}

.design--7 {
  top: 44%;
}

.design--8 {
  top: 56%;
}

/* states */
.flip-card .btn:hover+.design-container,
.flip-card .btn:active+.design-container,
.flip-card .btn:focus+.design-container,

.flip-card button:hover+.design-container,
.flip-card button:active+.design-container,
.flip-card button:focus+.design-container {
  --tr: 20;
  --op: .7;
}

There is an overflow on the mobile version (I only need help for the cards, I know that the rest isn’t mobile friendly as well). I want to center the cards without overflow.

3

Answers


  1. In your style.css file you have the following style declaration: .index-cards {margin: 0 100px;}. On mobile devices this is pushing your flip cards 100px to the right. You should change that to .index-cards {margin: 0 auto;} in a media query that addresses mobile screen sizes.

    Login or Signup to reply.
  2. Have you tried using media-queries? You can use them to adjust the cards when they are being rendered in a mobile phone. You can check media-queries here – https://www.w3schools.com/css/css3_mediaqueries_ex.asp

    Login or Signup to reply.
  3. As I understood, there is no need to display .index-cards div as a grid on mobile. What I suggest is that;

    @media screen and (max-width: 768px){
      .grid-3{
        display:block;
        margin: 0;
        /* remove these lines
          grid-template-columns: 1fr;
          grid-template-rows: 1fr;
        */
      }
      
      /* remove this margin
        .index-cards{
          margin: 0 100px;
        }
      */
    
      .flip-card-container{
        width:90%;
        margin: 0 auto 20px;
      }
    }

    I took a screenshot after editing, you can see it here.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search