简体   繁体   English

登陆页面文本隐藏在浏览器调整大小的图像下

[英]Landing page text hiding under image on browser resize

I don't understand why the text is going under the image before flex wrap comes into play.我不明白为什么在 flex wrap 发挥作用之前,文本会出现在图像下方。 I know it's probably something simple but I just can't figure it out.. I have put widths on both sides of the page, but they seem to be ignored when it comes to resizing, and the text goes almost completely behind the image before flex wrap drops it below (I want the image to be on top when that happens but I'll cross that bridge when I come to it, assuming I'll use a reverse property in flex).我知道这可能很简单,但我就是想不通。我在页面的两边都设置了宽度,但是在调整大小时它们似乎被忽略了,之前的文字几乎完全在图像后面flex wrap 将它放在下面(我希望图像在发生这种情况时位于顶部,但是当我遇到它时,我会越过那座桥,假设我将在 flex 中使用 reverse 属性)。 Anyway, not sure what is going on, and apologies for the probable mess of HTML and CSS.无论如何,不知道发生了什么,并为 HTML 和 CSS 的可能混乱道歉。

Thanks谢谢

    <div class="layout">
      <div class="left-sect">
        <img class="logo" src="./images/logo.svg" alt="site logo" />
        <div class="l-content">
          <h1 class="s-head">We're</h1>
          <h1>
            Coming <br />
            Soon
          </h1>
          <p>
            Hello fellow shoppers! We're currently building our new fashion
            store. Add your email below to stay up-to-date with announcements
            and our launch deals.
          </p>
          <input type="email" class="main-form" />
          <button type="submit">
            <img src="./images/icon-arrow.svg" alt="form button arrow" />
          </button>
        </div>
      </div>

      <div class="right-sect">
        <img class="main-img" src="./images/hero-desktop.jpg" alt="" />
      </div>
    </div>
  </body> 


CSS


 :root {
  --ds-red: hsl(0, 36%, 70%);
  --soft-red: hsl(0, 93%, 68%);
  --dg-red: hsl(0, 6%, 24%);
}

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

body {
  font-size: 16px;
  font-family: "Josefin Sans", sans-serif;
  background-image: url(./images/bg-pattern-desktop.svg);
  background-size: cover;
  background-position: center;
}


.layout {
  display: flex;
  flex-direction: row;
  /* flex-wrap: wrap; */
}

.left-sect {
  padding: 4rem 10rem;
  background-image: url(./images/bg-pattern-desktop.svg);
  background-size: cover;
  background-position: center;
  width: 60%;
}

.l-content {
  margin-top: 7rem;
}

.main-img {
}


.s-head {
  color: var(--ds-red);
  font-weight: 300;
  text-transform: uppercase;
  font-size: 4rem;
  letter-spacing: 1.2rem;
}

h1 {
  font-size: 4rem;
  letter-spacing: 1.2rem;
  text-transform: uppercase;
  color: var(--dg-red);
  font-weight: 400;
}

p {
  color: var(--ds-red);
  text-emphasis: left;
  width: 30rem;
  line-height: 1.3rem;
  margin-top: 1.5rem;
}

You sould add media queries.您应该添加媒体查询。

 :root { --ds-red: hsl(0, 36%, 70%); --soft-red: hsl(0, 93%, 68%); --dg-red: hsl(0, 6%, 24%); } * { margin: 0; padding: 0; box-sizing: border-box; } body { font-size: 16px; font-family: "Josefin Sans", sans-serif; background-size: cover; background-position: center; }.layout { display: flex; }.left-sect { padding: 4rem 10rem; background-image: url(./images/bg-pattern-desktop.svg); background-size: cover; background-position: center; width: 60%; }.l-content { margin-top: 7rem; }.main-img { }.s-head { color: var(--ds-red); font-weight: 300; text-transform: uppercase; font-size: 4rem; letter-spacing: 1.2rem; } h1 { font-size: 4rem; letter-spacing: 1.2rem; text-transform: uppercase; color: var(--dg-red); font-weight: 400; } p { color: var(--ds-red); text-emphasis: left; width: 30rem; line-height: 1.3rem; margin-top: 1.5rem; } @media screen and (max-width:1070px){/* <== You sould change this to what you want.*/ html.layout{ flex-direction:column; } @media screen and(min-width:1017px){ /* <== You sould change this to what you want.*/ html.layout{ flex-direction:row; } }
 <div class="layout"> <div class="left-sect"> <img class="logo" src="https://image.shutterstock.com/image-vector/dots-letter-c-logo-design-260nw-551769190.jpg" alt="site logo" /> <div class="l-content"> <h1 class="s-head">We're</h1> <h1> Coming <br /> Soon </h1> <p> Hello fellow shoppers. We're currently building our new fashion store. Add your email below to stay up-to-date with announcements and our launch deals. </p> <input type="email" class="main-form" /> <button type="submit"> <img src="./images/icon-arrow:svg" alt="form button arrow" /> </button> </div> </div> <div class="right-sect"> <img class="main-img" src="https.//image.shutterstock.com/image-vector/dots-letter-c-logo-design-260nw-551769190.jpg" alt="" /> </div>

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

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