简体   繁体   English

调整浏览器大小时,我的 div 容器溢出

[英]My div container is overflowing when the browser is resized

Did I mess up with the containers?我把容器弄乱了吗? I have two containers.我有两个容器。 One is the main and the second is the container for the text.一个是主要的,第二个是文本的容器。 What I meant is when I resize the browser the container of the text is overflowing and creating spaces for the side.我的意思是当我调整浏览器的大小时,文本的容器会溢出并为侧面创建空间。

This is my codepen: https://codepen.io/pen/WNGLqdd这是我的代码笔: https://codepen.io/pen/WNGLqdd

我的输出

My codes in scss我在 scss 中的代码

.banner {
  position: relative;
  display: flex;
  margin: 80px auto;
  @include sp {
    margin: getsp375(80px) auto;
  }

  &__img {
    display: block;
    width: 100%;
    height: 360px;
    @include sp {
      display: none;
    }

    &--sp {
      display: none;
      @include sp {
        display: block;
        width: 100%;
        height: auto;
      }
    }
  }

  &__text {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 36px;
    font-weight: $medium;
    text-align: center;
    @include sp {
      font-size: getps375(54px);
      font-weight: $regular;
      line-height: 1.3em;
      margin-left: getsp375(30px);
      margin-right: getsp375(30px);
    }

    &--small {
      font-size: 28px;
      @include sp {
        font-size: getsp375(42px);
      }
    }

    &--extra-small {
      position: absolute;
      top: -34px;
      left: 245px;
      font-size: 13px;
      line-height: 4.62em;
      @include sp {
        top: getps375(23px);
        left: getsp375(284px);
        font-size: getsp375(20px);
        line-height: 4.5em;
      }
    }

    &--description {
      padding-top: 25px;
      font-size: 16px;
      @include sp {
        line-height: auto;
        padding-top: getsp375(40px);
        font-size: getsp375(28px);
        font-weight: $regular;
      }
    }

    &--title {
      font-size: 50px;
      font-family: $nunito;
      font-weight: $bold;
      line-height: 0.83em;
      @include sp {
        font-size: getsp375(74px);
        line-height: 1.22em;
      }

      &::after {
        content: 'さん';
        font-weight: $medium;
      }
    }
  }

  &__container {
    position: absolute;
    display: block;
    left: 643px;
    width: 640px;
    max-width: 100%;
    height: 100%;
    @include sp {
      left: 0;
      margin-top: getsp375(57px);
      width: 100%;
      height: auto;
    }
  }

  &__text-container {
    position: relative;
    margin-top: 94px;
    width: 640px;
    max-width: 100%;
    @include sp {
      margin-top: 0;
      width: 100%;
    }

    &--second {
      margin-top: 124px;
      left: 30px;
      @include sp {
        margin-top: getsp375(125px);
        left: 0;
      }
    }
  }

  &__button-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    margin-top: 20px;
    margin-bottom: 60px;
    @include sp {
      margin-bottom: 0;
      margin-top: getsp375(138px);
    }

    &--second {
      @include sp {
        margin-bottom: 0;
        margin-top: getsp375(91px);
      }
    }
  }

  &__arc-container {
    margin-top: 36px;
    margin-left: 104px;
    width: 94.4%;
    @include sp {
      margin-top: 0;
      margin-left: 0;
    }
  }

  &__arc {
    background-repeat: no-repeat;
    position: absolute;
    width: 470px;
    height: 81px;
    @include sp {
      width: 100%;
      padding: 0 getsp375(21px);
      height: auto;
    }
  }
}

My codes in PUG我在 PUG 中的代码

section.banner
      img.banner__img(src="./img/banner__img1.jpg", alt="Banner 1")
      img.banner__img.banner__img--sp(src="./img/banner__img1-sp.jpg", alt="Banner 1")
      div.banner__container
        div.banner__text-container
          h1.banner__text.banner__text--small イベント企画‧まちづくりの⽅へ
          h1.banner__text ファンワッカがお⼿伝いします!
          p.banner__text.banner__text--description これはダミー文字です新型コロナウイルス緊急事態宣言解除後の当社対応についてのお知らせ 染まってないからこそ、新たな風を吹き込めるリアルをコアとした体験を
          div.banner__button-container
            a.button(href="#") 詳しく見る

I changed left to right and it will not give whitespaces from the left side when I resize the browser.我从左到右更改,当我调整浏览器大小时,它不会从左侧给出空格。

 &__container {
    position: absolute;
    display: block;
    right: 160px; //i changed this
    width: 640px;
    max-width: 100%;
    height: 100%;
    @include sp {
      right: 0;
      margin-top: getsp375(57px);
      width: 100%;
      height: auto;
    }
  }

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

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