【问题标题】:Footer at bottom of page for responsive screen页面底部的页脚用于响应式屏幕
【发布时间】:2021-08-28 22:41:27
【问题描述】:

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

我添加了 position: absolutebottom:0 但它会将页脚置于底部。如果分辨率发生变化,它会与内容重叠。

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

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

【问题讨论】:

    标签: html css reactjs sass


    【解决方案1】:
    • 您需要为“页脚容器”设置一个特定的高度,假设为 30vh 高度。
    • 您使用我们刚刚添加的页脚高度 (30vh) 作为主容器的 padding-bottom + set box-sizing to => "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;
    }
    }
    }
    

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

    【讨论】:

    • 它工作正常.. 我需要调整位以进行最终更改。谢谢
    猜你喜欢
    • 2016-01-18
    • 1970-01-01
    • 2013-04-29
    • 2019-03-05
    • 2013-08-19
    • 2015-08-30
    • 2013-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多