Divs的响应设计

发布于 2025-02-09 09:49:51 字数 385 浏览 1 评论 0原文

我有以下HTML代码(.CONTAINER内的DIV数量可能会有所不同)。
我想给它们一个最小的宽度,但否则它们应该填充屏幕的整个宽度。当屏幕的宽度太小(对于响应式设计)时,Divs应该简单地进入新线路。
看起来很简单,但是我一直在用梁,弯曲甚至漂浮的头敲打头,但似乎没有什么可用。没有人可以在不使用媒体查询的情况下提供帮助吗?

<div class="container">
    <div>pippo</div>
    <div>pluto</div>
    <div>paperino</div>
    <div>topolino</div>
</div>

I have the following HTML code (the number of divs within the .container can vary).
I want to give these a min width, but otherwise these should fill up the whole width of the screen. When the width of the screen is too small (for responsive designs) the divs should simply go on a new line.
It seems simple, but I've been banging my head with gird, flex and even float, but nothing seems to work. Anybody can help without using media queries?

<div class="container">
    <div>pippo</div>
    <div>pluto</div>
    <div>paperino</div>
    <div>topolino</div>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若有似无的小暗淡 2025-02-16 09:49:51

使用flex-wrap:wrap;当没有DIV空间时,DIV包裹到下一行。

我也使用Jusify-content:space-betew;填充屏幕的整个宽度

.container {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: wrap;
}
<div class="container">
  <div>pippo</div>
  <div>pluto</div>
  <div>paperino</div>
  <div>topolino</div>
</div>

with flex-wrap: wrap; when there was no space for div, div wrap to the next line.

also i use justify-content: space-between; to fill up the whole width of the screen

.container {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: wrap;
}
<div class="container">
  <div>pippo</div>
  <div>pluto</div>
  <div>paperino</div>
  <div>topolino</div>
</div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文