簡體   English   中英

調整瀏覽器大小時,我的 div 容器溢出

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

我把容器弄亂了嗎? 我有兩個容器。 一個是主要的,第二個是文本的容器。 我的意思是當我調整瀏覽器的大小時,文本的容器會溢出並為側面創建空間。

這是我的代碼筆: https://codepen.io/pen/WNGLqdd

我的輸出

我在 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;
    }
  }
}

我在 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="#") 詳しく見る

我從左到右更改,當我調整瀏覽器大小時,它不會從左側給出空格。

 &__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