简体   繁体   English

如何制作这种响应式设计?

[英]How to make this responsive design?

I want to make this responsive design using html and css with flexbox:我想使用 html 和 css 和 flexbox 来制作这个响应式设计: 小的 大中型

this is my code:这是我的代码:

 span { font-weight: bold; color: aqua; } .parent { display: flex; width: 100%; height: 100px; background-color: white; justify-content: space-around; align-items: center; } .child { display: flex; width: 18%; height: 71px; background-color: #eee; align-items: center; justify-content: center; } /*small screen*/ @media (max-width: 991px) { span { font-weight: bold; color: black; } .parent { display: flex; width: 100%; background-color: white; justify-content: space-around; align-items: center; flex-wrap: wrap; } .child { display: flex; width: 100%; height: 71px; background-color: #eee; align-items: center; justify-content: center; margin-bottom: 10px; } } /*medium screen*/ @media (min-width: 992px) { span { font-weight: bold; color: red; } .parent { display: flex; width: 100%; background-color: white; align-items: center; flex-wrap: wrap; } .child { display: flex; width: 45%; height: 71px; background-color: #eee; align-items: center; justify-content: center; margin-bottom: 15px; } } /*large screen*/ @media (min-width: 1200px) { span { font-weight: bold; color: aqua; } .parent { display: flex; width: 100%; height: 100px; background-color: white; justify-content: space-around; align-items: center; } .child { display: flex; width: 18%; height: 71px; background-color: #eee; align-items: center; justify-content: center; } }
 <div class="parent"> <div class="child"><span>Product one</span>This Is Product</div> <div class="child"><span>Product two</span>This Is Product</div> <div class="child"><span>Product three</span>This Is Product</div> <div class="child"><span>Product four</span>This Is Product</div> </div>

there is many differences between my code and the design above how can I fix the problems in the code to have like this design?我的代码和上面的设计之间有很多差异,我该如何解决代码中的问题,使之像这样的设计? small screen: max-width: 991px.小屏幕:最大宽度:991px。 medium screen: min-width: 992px.中等屏幕:最小宽度:992px。 large screen: min-width: 1200px.大屏幕:最小宽度:1200px。

You should add flex-direction:column;您应该添加flex-direction:column; to .child class.到 .child 类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM