flex-框不是包装框

发布于 2025-01-20 04:03:48 字数 1519 浏览 1 评论 0原文

我已经制作了.main_area flexbox,其中有两个元素,但Flex-wrap无法正常工作。 我希望,如果我在820px屏幕上打开它,那么它应该是对此的解决方案

.main_area {
      display: flex;
      flex-wrap: wrap;
      /* background-color: burlywood; */
      height: 80vh;
      width: 100%;
    }
    .picture_area {
      display: flex;
      align-items:baseline;
      justify-content: flex-end;
      /* background-color: red; */
      height: 80vh;
      width: 50%;
    }
    .picture_area img {
      height: 100%;
      /* width: 100%; */
      float: right;
      filter: grayscale(1);
    }
    .content_area {
      /* background-color: blue; */
      height: 80vh;
      width: 30%;
      flex-direction: column;
      align-items: center;
      justify-content:center;
    }```

the html code is
``` <div class="main_area">
      <div class="picture_area" id="picture_area">
        <img src="./Cartoons_Bugs_Tunes_Looney_Bunny_Bugs_bunny_HD_Wallpapers-removebg.png" alt="">
      </div>
      <div class="content_area d-flex" id="content_area">
        <h1 class="UI_pattern">UI Problem</h1>
        <h1 class="UI_pattern">solver</h1>
        <p class="UI_para">And this is why my competitors</p>
        <p class="UI_para">Simply call me 'Revolver'</p>
        <input type="text" class="Busi_email" placeholder="Type your business email">
        <button class="UI_button">Get in touch</button>
      </div>
    </div>

I have made the .main_area a flexbox and it has two elements in it but flex-wrap is not working.
I want that if i open it on 820px screen then it shouldautomaticaly wrap is there a solution to this

.main_area {
      display: flex;
      flex-wrap: wrap;
      /* background-color: burlywood; */
      height: 80vh;
      width: 100%;
    }
    .picture_area {
      display: flex;
      align-items:baseline;
      justify-content: flex-end;
      /* background-color: red; */
      height: 80vh;
      width: 50%;
    }
    .picture_area img {
      height: 100%;
      /* width: 100%; */
      float: right;
      filter: grayscale(1);
    }
    .content_area {
      /* background-color: blue; */
      height: 80vh;
      width: 30%;
      flex-direction: column;
      align-items: center;
      justify-content:center;
    }```

the html code is
``` <div class="main_area">
      <div class="picture_area" id="picture_area">
        <img src="./Cartoons_Bugs_Tunes_Looney_Bunny_Bugs_bunny_HD_Wallpapers-removebg.png" alt="">
      </div>
      <div class="content_area d-flex" id="content_area">
        <h1 class="UI_pattern">UI Problem</h1>
        <h1 class="UI_pattern">solver</h1>
        <p class="UI_para">And this is why my competitors</p>
        <p class="UI_para">Simply call me 'Revolver'</p>
        <input type="text" class="Busi_email" placeholder="Type your business email">
        <button class="UI_button">Get in touch</button>
      </div>
    </div>

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

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

发布评论

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

评论(2

薔薇婲 2025-01-27 04:03:48

您可能忘记在 CSS 语句之前添加选择器吗?

.main-area{      
      display: flex;
      flex-wrap: wrap;
      /* background-color: burlywood; */
      height: 80vh;
      width: 100%;
    }

Might have you forgotten to add the selector before your CSS statement?

.main-area{      
      display: flex;
      flex-wrap: wrap;
      /* background-color: burlywood; */
      height: 80vh;
      width: 100%;
    }
尘世孤行 2025-01-27 04:03:48

这应该对您有效:

.main_area {
  display: flex;
  flex-wrap: wrap;
  /* background-color: burlywood; */
  height: 80vh;
  width: 100%;
}

.picture_area {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  /* background-color: red; */
  height: 80vh;
  width: 50%;
}

.picture_area img {
  height: 100%;
  /* width: 100%; */
  float: right;
  filter: grayscale(1);
}

.content_area {
  /* background-color: blue; */
  height: 80vh;
  width: 30%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

img {
  max-width: 100%;
}

@media only screen and (max-width: 820px) {
  .main_area {
    display: flex;
    flex-wrap: wrap;
    flex-flow: column;
    align-items: center;
    justify-content: center;
  }
}
<div class="main_area">
  <div class="picture_area" id="picture_area">
    <img src="https://dummyimage.com/600x400/000/fff" alt="">
  </div>
  <div class="content_area d-flex" id="content_area">
    <h1 class="UI_pattern">UI Problem</h1>
    <h1 class="UI_pattern">solver</h1>
    <p class="UI_para">And this is why my competitors</p>
    <p class="UI_para">Simply call me 'Revolver'</p>
    <input type="text" class="Busi_email" placeholder="Type your business email">
    <button class="UI_button">Get in touch</button>
  </div>
</div>

This should work nicely for you:

.main_area {
  display: flex;
  flex-wrap: wrap;
  /* background-color: burlywood; */
  height: 80vh;
  width: 100%;
}

.picture_area {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  /* background-color: red; */
  height: 80vh;
  width: 50%;
}

.picture_area img {
  height: 100%;
  /* width: 100%; */
  float: right;
  filter: grayscale(1);
}

.content_area {
  /* background-color: blue; */
  height: 80vh;
  width: 30%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

img {
  max-width: 100%;
}

@media only screen and (max-width: 820px) {
  .main_area {
    display: flex;
    flex-wrap: wrap;
    flex-flow: column;
    align-items: center;
    justify-content: center;
  }
}
<div class="main_area">
  <div class="picture_area" id="picture_area">
    <img src="https://dummyimage.com/600x400/000/fff" alt="">
  </div>
  <div class="content_area d-flex" id="content_area">
    <h1 class="UI_pattern">UI Problem</h1>
    <h1 class="UI_pattern">solver</h1>
    <p class="UI_para">And this is why my competitors</p>
    <p class="UI_para">Simply call me 'Revolver'</p>
    <input type="text" class="Busi_email" placeholder="Type your business email">
    <button class="UI_button">Get in touch</button>
  </div>
</div>

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