English 中文(简体)
我想将弹性卡从5个增加到3个(中心)和反应性[封闭式]。
原标题:I want to make flex cards from 5 to 3 (center) and responsive [closed]
Closed. This question needs debugging details. It is not currently accepting answers.

I want to create a flex (or maybe a grid or bootstrap) (I want to use white space as well, about 40px) From 5 to 3 top and 2 bottom (middle) and change to 1 big card and 2 small cards per row. What should I do to find the best way? I m not sure which method is best. Or which method is correct? While I m building a website It s like I did it the wrong way. And my work didn t turn out very well.

My problem is the dynamics and width of the card when reducing the screen size. I would like the card to be able to reduce its width a bit before changing the format. What I do now is I write 5 cards to use. Justify content center with media query (used to reduce the width of the flex container, causing the card to drop to the bottom) There are always a lot of problems and I don t know how to deal with them. (Dynamic even numbers and odd numbers are displayed differently)

demo

问题回答

*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body{
  font-family: Arial, Helvetica, sans-serif;
}

.wrap{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 40px;
  max-width: 1200px;
  width: 100%;
  padding: 30px;
  margin: auto;
}

.wrap .box{
  flex: 1;
  border: 1px solid #000;
  background: #ddd;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* responsive */

/* on tablet */
@media(max-width: 767px){
  .wrap .box{
    flex: none;
    width: calc(33.3333333% - 40px);
  }
}

/* on phone */
@media(max-width: 576px){
  .wrap{
    gap: 30px;
  }
  .wrap .box{
    max-height: 300px;
    width: calc(50% - 15px);
  }
  .wrap .box-1{
    width: 100%;
    aspect-ratio: 1 / .5;
  }
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <div class="wrap">
    <div class="box box-1">1</div>
    <div class="box">2</div>
    <div class="box">3</div>
    <div class="box">4</div>
    <div class="box">5</div>
  </div>

</body>
</html>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签