【问题标题】:Problem with responsiveness - Text in Hero-image响应性问题 - Hero-image 中的文本
【发布时间】:2021-11-13 02:19:52
【问题描述】:

我需要帮助。 我想创建一个英雄形象,但我无法定位文本。 我希望它看起来像这样: enter image description here

当我按照自己的方式进行操作时,稍后我会遇到 RWD 定位问题。 也许可以以某种更简单的方式做到这一点?

  <header>
          <div class="hero-img">
              <div class="hero-shadow"></div>
              <div class="hero-text">
                  <h1>Zięba</h1>
                  <p>gallery</p>
                </div>
                <i class="fas fa-chevron-down"></i>
      </header>

header {
.hero-img {
    position: relative;
    height: 100vh;
    width: 100vw;
    background-image: url('../img/Kapiaca-sie-small.jpg');
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
    z-index: -2;
    overflow: hidden;

    .fa-chevron-down {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        top: 95%;
        color: $white-color;
        font-size: 35px;
    }
}

.hero-text {
    position: absolute;
    transform: translate(1430px, -50px);
    height: 100%;
    z-index: 5;

    h1 {
        color: $black-color;
        font-size: 30rem;
        font-family: 'Disclaimer', sans-serif;
    }

    h1::before {
        content: 'Sławomir';
        position: absolute;
        display: inline-block;
        transform: rotate(270deg);
        top: 312px;
        right: 180px;
        font-size: 5rem;
        font-family: 'Roboto', sans-serif;
        color: $green-color;
    }

    p { position: absolute;
        top: 540px;
        right: 10px;
        text-transform: uppercase;
        color: $brown-color;
        font-size: 1.6rem;
    }
}

我正在发送 CodePen 的链接:https://codepen.io/Ewelaa/pen/MWoVwvY

【问题讨论】:

    标签: sass position responsive positioning hero


    【解决方案1】:
    header .hero-text {
      position: absolute;
      right:40px;
      height: 100%;
      z-index: 5;
    }  
    

    只需使用 Right 属性来固定位置。

    【讨论】:

      猜你喜欢
      • 2018-12-01
      • 2021-09-23
      • 2021-09-06
      • 1970-01-01
      • 1970-01-01
      • 2019-04-08
      • 2020-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多