Web实现:页面底部栏实例

78 篇文章 2 订阅
68 篇文章 0 订阅

HTML部分:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link rel="stylesheet" href="./index.css" />
    <title>移动端问吧首页</title>
  </head>
  <body>
    <footer class="footer">
      <div class="item item-selected">
        <span class="icon footer-icon1"></span>
        <span class="txt">首页</span>
      </div>
      <div class="item">
        <span class="icon footer-icon2"></span>
        <span class="txt">练习</span>
      </div>
      <div class="item">
        <span class="icon footer-icon3"></span>
        <span class="txt">消息</span>
      </div>
      <div class="item">
        <span class="icon footer-icon4"></span>
        <span class="txt">我的</span>
      </div>
    </footer>
  </body>
</html>

CSS部分:

html,
body {
  height: 100%;
  margin: 0; }

ul,
li {
  margin: 0;
  padding: 0; }

li {
  list-style: none; }

h1,
h2 {
  margin: 0; }

p {
  margin: 0;
  padding: 0; }

@media screen and (max-width: 768px) {
  html {
    font-size: 20px; } }

@media screen and (max-width: 320px) {
  html {
    font-size: 17.0666666667px; } }

.btn {
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer; }
  .btn:focus {
    outline: none; }

body {
  max-width: 768px;
  margin: 0 auto; }

.footer {
  max-width: 768px;
  height: 2.45rem;
  margin: 0 auto;
  box-sizing: border-box;
  background: #FFFFFF;
  border-top: 1px solid #E1E1E1;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 2.3rem;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10; }
  .footer .item {
    text-align: center;
    font-size: 0.5rem;
    line-height: 0.7rem;
    color: #666666;
    padding-bottom: 0.175rem; }
    .footer .item-selected {
      color: #3492FD; }
    .footer .item:nth-child(1) .icon {
      background: url(./images/footer-icon1.png) no-repeat center/contain; }
    .footer .item:nth-child(2) .icon {
      background: url(./images/footer-icon2.png) no-repeat center/contain; }
    .footer .item:nth-child(3) .icon {
      background: url(./images/footer-icon3.png) no-repeat center/contain; }
    .footer .item:nth-child(4) .icon {
      background: url(./images/footer-icon4.png) no-repeat center/contain; }
    .footer .item:nth-child(1) .icon, .footer .item:nth-child(4) .icon {
      margin-bottom: 0.125rem; }
    .footer .item:nth-child(2) .icon {
      margin-bottom: 0.05rem; }
    .footer .item:nth-child(3) .icon {
      margin-bottom: 0.1rem; }
    .footer .item .icon {
      width: 1.2rem;
      height: 1.2rem;
      display: block; }

/*scss代码如下:*/

/*html,
body {
  height: 100%;
  margin: 0;
}

ul,
li {
  margin: 0;
  padding: 0;
}
li {
  list-style: none;
}

h1,
h2 {
  margin: 0;
}

p {
  margin: 0;
  padding: 0;
}

// 浏览器都有自己的默认样式,以上部分为清除浏览器默认样式

@media screen and (max-width: 768px) {
  html {
    font-size: 20px;
  }
}

@media screen and (max-width: 320px) {
  html {
    font-size: 20px / 375 * 320;
  }
}

@function px2rem($px) {
  @return #{$px / 40}rem;
}

.btn {
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  &:focus {
    outline: none;
  }
}

$maxWidth: 768px;

body {
  max-width: $maxWidth;
  margin: 0 auto;
}

.footer {
  max-width: $maxWidth;
  height: px2rem(98);
  margin: 0 auto;
  box-sizing: border-box;
  background: #FFFFFF;
  border-top: 1px solid #E1E1E1;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 px2rem(92);

  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  
  .item {
    text-align: center;
    font-size: px2rem(20);
    line-height: px2rem(28);
    color: #666666;
    padding-bottom: px2rem(7);
    &-selected {
      color: #3492FD;
    }
    @for $i from 1 to 5 {
      &:nth-child(#{$i}) .icon {
        background: url(./images/footer-icon#{$i}.png) no-repeat center / contain;
      }
    }
    &:nth-child(1), &:nth-child(4){
      .icon {
        margin-bottom: px2rem(5);
      }
    }
    &:nth-child(2) .icon {
      margin-bottom: px2rem(2);
    }
    &:nth-child(3) .icon {
      margin-bottom: px2rem(4);
    }
    .icon {
      width: px2rem(48);
      height: px2rem(48);
      display: block;
    }
  }
}
*/
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jasmyn518

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值