响应式屏幕页面底部的页脚

时间:2021-06-12 06:38:33

标签: html css reactjs sass

我希望页脚位于页面底部和底部边界上方 43 像素处。如果屏幕分辨率发生变化,则不应与内容重叠。下面的 css 是 1920 尺寸的。我希望它也能响应其他维度。

我添加了 position: absolutebottom:0 但它将页脚放在底部。如果分辨率改变,它会与内容重叠。

ma​​rgin-top:自动也不起作用。

HTML

<div className="col-md-12 p-0 login-page">
   <div className="main-container">
     <div className="wrapLoginPage">
        <div className="content">

          <div className="img-logo">
            <img src={GooglerLogo} alt="Logo" height={58} width={95} />
          </div>
          <div  className="img-caption">
            MI jjfkjd  fdnfjdjf fjndjfdjf dfjdjfjdnfjdfdf
          </div>

          // .login-div (css)
          {this._renderLoginForm()}

          <div className="footer-container">
            <div className="footer-img">
                <img src={AppleLogo} alt="Apple Logo" height={48} width={48}/>
            </div>
            <div className="footer-text">
              Lorem ipsum footr content dfd dfdgfdgfd
            </div>
          </div>
        </div>

          <div className="left-container">
              {/* <img src={SampleImg} alt="Sample" height={840} width={1350} /> */}
          </div>

     </div>
   </div>
 </div>

CSS

// Login Page
@import "../mixins.scss";

.login-page {
  width: 100%;
  margin: 0 auto;

  .main-container {
    width: 100%;  
    min-height: 100vh;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
  }

  .left-container {
    display: flex;
    width: calc(100% - 490px);
    background: linear-gradient(to bottom, #f7f7fc 60%, #F2D8FF 40%);
    position: relative;
  }

  .wrapLoginPage {
    width: 100%;
    background: #fff;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    flex-direction: row-reverse;
  }

  .content {
    width: 490px;
    min-height: 100vh;
    display: block;
    background-color: #fff;
    padding: 101px 50px 43px 44px;
  }

  .img-logo {
    padding-bottom: 18px;
  }
  .img-caption {
    color: #1C2C42;
    font-size: 18px;
    line-height: 24px;
    font-weight: 400;
    padding-bottom: 113px;
  }

  
  .login-div {
    width: 100%;
    display: inline-block;
  }
 

  .footer-container {
    position: absolute;
    bottom: 0;
    display: flex;
    align-items: center;
    
    .footer-text {
      width: 297px;
      font-style: normal;
      font-weight: 500;
      font-size: 12px;
      line-height: 18px;
      color: #575E6B;
      padding-left: 12px;
    }
  }
}

This is the screen image

1 个答案:

答案 0 :(得分:0)

  • 您需要为“页脚-容器”设置特定的高度,假设高度为 30vh。
  • 您使用我们刚刚添加的页脚高度 (30vh) 作为主容器的 padding-bottom + 将 box-sizing 设置为 => "border-box" Box-sizing 允许所选元素的填充为高度的“一部分”(100vh)
  • 也许你需要防止在小屏幕上出现一些换行或溢出,即使这不是非常漂亮,我应该在页脚容器中添加一个溢出:自动。

所以结果 CSS :

// Login Page
@import "../mixins.scss";

.login-page {
    width: 100%;
    margin: 0 auto;

.main-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.left-container {
    display: flex;
    width: calc(100% - 490px);
    background: linear-gradient(to bottom, #f7f7fc 60%, #F2D8FF 40%);
    position: relative;
}

.wrapLoginPage {
    width: 100%;
    background: #fff;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    flex-direction: row-reverse;
}

.content {
    width: 490px;
    min-height: 100vh;
    display: block;
    background-color: #fff;
    padding: 101px 50px 30vh 44px;
    box-sizing: border-box;
}

.img-logo {
    padding-bottom: 18px;
}
.img-caption {
    color: #1C2C42;
    font-size: 18px;
    line-height: 24px;
    font-weight: 400;
    padding-bottom: 113px;
}


.login-div {
    width: 100%;
    display: inline-block;
}


.footer-container {
    position: absolute;
    bottom: 0;
    display: flex;
    align-items: center;

.footer-text {
    width: 297px;
    font-style: normal;
    font-weight: 500;
    font-size: 12px;
    line-height: 18px;
    color: #575E6B;
    padding-left: 12px;
    height: 30vh;
    overflow: auto;
}
}
}

希望我已经很清楚你在找什么了:)