css 我怎样才能消除移动的版的溢出并将卡居中?

55ooxyrt  于 2023-04-13  发布在  其他
关注(0)|答案(3)|浏览(121)

我试了这么多,但我不能修复溢出,只是中心的翻转卡。我也有一个网址到dummy website
有人能帮帮我吗?我不知道该怎么办

<!-- 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;
}

移动的版有一个溢出(我只需要帮助卡,我知道,其余的是不移动友好以及)。我想中心卡没有溢出。

vlju58qv

vlju58qv1#

在style.css文件中,有以下样式声明:.index-cards {margin: 0 100px;}。在移动的设备上,这会将您的翻盖卡向右推100px。您应该在解决移动屏幕尺寸的媒体查询中将其更改为.index-cards {margin: 0 auto;}

zfciruhq

zfciruhq2#

你试过使用媒体查询吗?你可以使用它们来调整卡片,当它们在移动的中呈现时。你可以在这里检查媒体查询-https://www.w3schools.com/css/css3_mediaqueries_ex.asp

cl25kdpy

cl25kdpy3#

据我所知,没有必要在移动的上将.index-cards div显示为grid

@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;
  }
}

我编辑后截图,你可以看到它here

相关问题