使用less插件编写b站移动端网页

这是一个关于网页设计的HTML、CSS和LESS文件示例。HTML文件包含网站头部导航和主体内容,展示了多个带有图片、播放次数和评论数的卡片式布局。CSS文件和LESS文件定义了样式,包括字体、颜色、布局和图标等,提供了响应式的视觉效果。
摘要由CSDN通过智能技术生成

 根文件夹

HTML文件

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">
  <link rel="stylesheet" href="./fonts/iconfont.css">
  <link rel="stylesheet" href="./css/index.css">
  <title>哔哩哔哩 (゜-゜)つロ 干杯~-bilibili</title>
</head>

<body>
  <!-- 头部开始 -->
  <div class="header">
    <div class="main">
      <a href="" class="logo">
        <i class="iconfont Navbar_logo"></i>
      </a>
      <div class="right">
        <a href="" class="search">
          <i class="iconfont ic_search_tab"></i>
        </a>
        <a href="" class="face">
          <img src="./images/login1.png" alt="">
        </a>
        <a href="" class="launch">
          <img src="./images/download.png" alt="">
        </a>
      </div>
    </div>
    <div class="nav">
      <ul>
        <li><a href="">首页</a></li>
        <li><a href="">动画</a></li>
        <li><a href="">番剧</a></li>
        <li><a href="">果蔬</a></li>
        <li><a href="">音乐</a></li>
        <li><a href="">舞蹈</a></li>

        <div class="line"></div>
      </ul>
      <span class="after iconfont"></span>
    </div>
  </div>
  <!-- 头部结束 -->
  <!-- 主体开始 -->
  <main>
    <div class="pic">
      <a href="#">
        <div class="card">
          <img src="./images/banner.webp" alt="">
          <div class="count">
            <span> <i class="iconfont"></i> 183.9万</span>
            <span> <i class="iconfont"></i> 7029</span>
          </div>
        </div>
        <div class="title">
          <p>东 汉 变 种 人</p>
        </div>

      </a>
    </div>
    <div class="pic">
      <a href="#">
        <div class="card">
          <img src="./images/banner1.webp" alt="">
          <div class="count">
            <span> <i class="iconfont"></i> 23.3万</span>
            <span> <i class="iconfont"></i> 2239</span>
          </div>
        </div>
        <div class="title">
          <p>【自制】我做了一把 模 块 化 机 械 键 盘 !【软核】</p>
        </div>

      </a>
    </div>
    <div class="pic">
      <a href="#">
        <div class="card">
          <img src="./images/banner2.webp" alt="">
          <div class="count">
            <span> <i class="iconfont"></i> 253.6万</span>
            <span> <i class="iconfont"></i> 3.5万</span>
          </div>
        </div>
        <div class="title">
          <p>《原神》须弥前瞻短片02——细雨与飞沙</p>
        </div>

      </a>
    </div>
    <div class="pic">
      <a href="#">
        <div class="card">
          <img src="./images/banner3.webp" alt="">
          <div class="count">
            <span> <i class="iconfont"></i> 79.8万</span>
            <span> <i class="iconfont"></i> 696</span>
          </div>
        </div>
        <div class="title">
          <p>实拍立体机动装置!燃烧的经费!燃烧的梦想!</p>
        </div>

      </a>
    </div>
    <div class="pic">
      <a href="#">
        <div class="card">
          <img src="./images/banner4.webp" alt="">
          <div class="count">
            <span> <i class="iconfont"></i> 108.4万</span>
            <span> <i class="iconfont"></i> 1428</span>
          </div>
        </div>
        <div class="title">
          <p>第一次坐牢是什么体验</p>
        </div>

      </a>
    </div>
    <div class="pic">
      <a href="#">
        <div class="card">
          <img src="./images/banner5.webp" alt="">
          <div class="count">
            <span> <i class="iconfont"></i> 66.1万</span>
            <span> <i class="iconfont"></i> 5927</span>
          </div>
        </div>
        <div class="title">
          <p>翻出七年前的同学录,我好像错过了她。</p>
        </div>

      </a>
    </div>
    <div class="pic">
      <a href="#">
        <div class="card">
          <img src="./images/banner6.webp" alt="">
          <div class="count">
            <span> <i class="iconfont"></i> 105.1万</span>
            <span> <i class="iconfont"></i> 7004</span>
          </div>
        </div>
        <div class="title">
          <p>舅舅我啊,最喜欢二次元了!</p>
        </div>

      </a>
    </div>
    <div class="pic">
      <a href="#">
        <div class="card">
          <img src="./images/banner7.webp" alt="">
          <div class="count">
            <span> <i class="iconfont"></i> 229.3万</span>
            <span> <i class="iconfont"></i> 681</span>
          </div>
        </div>
        <div class="title">
          <p>一定要和喜欢的人坐双层火车去大理!!!</p>
        </div>

      </a>
    </div>
    <div class="pic">
      <a href="#">
        <div class="card">
          <img src="./images/banner8.webp" alt="">
          <div class="count">
            <span> <i class="iconfont"></i> 70.9万</span>
            <span> <i class="iconfont"></i> 5996</span>
          </div>
        </div>
        <div class="title">
          <p>谭sir直播带货了!他掉坑里了!他翻车了!</p>
        </div>

      </a>
    </div>
    <div class="pic">
      <a href="#">
        <div class="card">
          <img src="./images/banner9.webp" alt="">
          <div class="count">
            <span> <i class="iconfont"></i> 186.8万</span>
            <span> <i class="iconfont"></i> 2.9万</span>
          </div>
        </div>
        <div class="title">
          <p>当我第一次打开MC</p>
        </div>

      </a>
    </div>
  </main>
  <!-- 主体结束 -->
  <!-- 输出开始 -->
  <div class="openApp">
    <div class="info">
      <div class="logo">
        <i class="iconfont Navbar_logo"></i>
      </div>
      <span>打开App,看你感兴趣的视频</span>
    </div>
  </div>

  <!-- 输出结束 -->
</body>

</html>

css文件 

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
body {
  font-family: Helvetica Neue, Tahoma, Arial, PingFangSC-Regular, Hiragino Sans GB, Microsoft Yahei, sans-serif;
}
a {
  color: #333;
  text-decoration: none;
}
img {
  vertical-align: middle;
  width: 100%;
  height: 100%;
}
ul {
  list-style: none;
}
.ellipsis-2 {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.header {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  width: 100%;
  background-color: #fff;
}
.header .main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 3.2vw 0 4.8vw;
  width: 100%;
  height: 11.73333333vw;
}
.header .main .logo i {
  font-size: 28px;
  color: #FB7299;
}
.header .main .right {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.header .main .right .search {
  color: #ccc;
}
.header .main .right .search i {
  font-size: 5.86666667vw;
}
.header .main .right .face {
  width: 6.4vw;
  height: 6.4vw;
  margin: 0 6.4vw;
}
.header .main .right .launch {
  width: 19.2vw;
  height: 6.4vw;
}
.header .nav {
  position: relative;
  flex: 1;
  height: 10.66666667vw;
  border-bottom: 1px solid #f4f4f4;
  background-color: #fff;
}
.header .nav ul {
  position: relative;
  display: flex;
  justify-content: space-between;
  padding: 0 3.2vw 0 4.8vw;
  width: 100%;
}
.header .nav ul li {
  display: flex;
}
.header .nav ul li:first-child a {
  color: #FB7299;
}
.header .nav ul li a {
  line-height: 10.66666667vw;
  font-size: 3.73333333vw;
}
.header .nav ul .line {
  position: absolute;
  transform: translate(18 / 3.75vw);
  bottom: 0;
  width: 7.46666667vw;
  height: 0.53333333vw;
  background-color: #FB7299;
}
.header .nav .after {
  position: absolute;
  right: 0;
  top: 0;
  width: 10.66666667vw;
  height: 10.66666667vw;
  text-align: center;
}
.header .nav .after::after {
  content: '\e6eb';
  line-height: 10.66666667vw;
  background-color: #fff;
}
main {
  margin-top: 22.4vw;
  padding: 0 1.33333333vw;
  display: flex;
  flex-wrap: wrap;
}
main .pic {
  padding: 2.13333333vw 1.33333333vw;
  width: 50%;
}
main .pic a .card {
  position: relative;
  width: 45.86666667vw;
}
main .pic a .card img {
  width: 100%;
}
main .pic a .card .count {
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  width: 100%;
  background-image: linear-gradient(transparent, #000);
  padding: 1.33333333vw 1.6vw;
  height: 7.46666667vw;
}
main .pic a .card .count span {
  font-size: 3.2vw;
  color: #fff;
}
main .pic a .card .count span:first-child i::before {
  content: '\e617';
}
main .pic a .card .count span:last-child i::before {
  content: '\e616';
}
main .pic a .title {
  width: 100%;
  margin-top: 1.6vw;
}
main .pic a .title p {
  font-size: 3.2vw;
}
.openApp {
  width: 100%;
  position: fixed;
  left: 0;
  bottom: 8vw;
}
.openApp .info {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 94%;
  height: 9.86666667vw;
  margin: 0 auto ;
  border-radius: 4.8vw;
  background-color: #FB7299;
  color: #fff;
}
.openApp .info .logo {
  font-size: 4.26666667vw;
  margin-right: 4vw;
}
.openApp .info span {
  font-size: 3.73333333vw;
}

less文件

base.less

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
body {
  font-family: Helvetica Neue, Tahoma, Arial, PingFangSC-Regular, Hiragino Sans GB, Microsoft Yahei, sans-serif;
}
a {
  color: #333;
  text-decoration: none;
}
img {
  vertical-align: middle;
  width: 100%;
  height: 100%;
}
ul {
  list-style: none;
}
.ellipsis-2 {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.header {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  width: 100%;
  background-color: #fff;
}
.header .main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 3.2vw 0 4.8vw;
  width: 100%;
  height: 11.73333333vw;
}
.header .main .logo i {
  font-size: 28px;
  color: #FB7299;
}
.header .main .right {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.header .main .right .search {
  color: #ccc;
}
.header .main .right .search i {
  font-size: 5.86666667vw;
}
.header .main .right .face {
  width: 6.4vw;
  height: 6.4vw;
  margin: 0 6.4vw;
}
.header .main .right .launch {
  width: 19.2vw;
  height: 6.4vw;
}
.header .nav {
  position: relative;
  flex: 1;
  height: 10.66666667vw;
  border-bottom: 1px solid #f4f4f4;
  background-color: #fff;
}
.header .nav ul {
  position: relative;
  display: flex;
  justify-content: space-between;
  padding: 0 3.2vw 0 4.8vw;
  width: 100%;
}
.header .nav ul li {
  display: flex;
}
.header .nav ul li:first-child a {
  color: #FB7299;
}
.header .nav ul li a {
  line-height: 10.66666667vw;
  font-size: 3.73333333vw;
}
.header .nav ul .line {
  position: absolute;
  transform: translate(18 / 3.75vw);
  bottom: 0;
  width: 7.46666667vw;
  height: 0.53333333vw;
  background-color: #FB7299;
}
.header .nav .after {
  position: absolute;
  right: 0;
  top: 0;
  width: 10.66666667vw;
  height: 10.66666667vw;
  text-align: center;
}
.header .nav .after::after {
  content: '\e6eb';
  line-height: 10.66666667vw;
  background-color: #fff;
}
main {
  margin-top: 22.4vw;
  padding: 0 1.33333333vw;
  display: flex;
  flex-wrap: wrap;
}
main .pic {
  padding: 2.13333333vw 1.33333333vw;
  width: 50%;
}
main .pic a .card {
  position: relative;
  width: 45.86666667vw;
}
main .pic a .card img {
  width: 100%;
}
main .pic a .card .count {
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  width: 100%;
  background-image: linear-gradient(transparent, #000);
  padding: 1.33333333vw 1.6vw;
  height: 7.46666667vw;
}
main .pic a .card .count span {
  font-size: 3.2vw;
  color: #fff;
}
main .pic a .card .count span:first-child i::before {
  content: '\e617';
}
main .pic a .card .count span:last-child i::before {
  content: '\e616';
}
main .pic a .title {
  width: 100%;
  margin-top: 1.6vw;
}
main .pic a .title p {
  font-size: 3.2vw;
}
.openApp {
  width: 100%;
  position: fixed;
  left: 0;
  bottom: 8vw;
}
.openApp .info {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 94%;
  height: 9.86666667vw;
  margin: 0 auto ;
  border-radius: 4.8vw;
  background-color: #FB7299;
  color: #fff;
}
.openApp .info .logo {
  font-size: 4.26666667vw;
  margin-right: 4vw;
}
.openApp .info span {
  font-size: 3.73333333vw;
}

index.less

@import './base.less';

@baseSize: 3.75vw;

// 头部
.header {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  width: 100%;
  background-color: #fff;
  .main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 (12 / @baseSize) 0 (18 / @baseSize);
    width: 100%;
    height: (44 / @baseSize);

    .logo{

      i {
       font-size: 28px;
       color: #FB7299;
      }
    }
    .right {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .search {
        
        color: #ccc;
        i {
          font-size: (22 / @baseSize);
        }
      }
      .face {
        width: (24 / @baseSize);
        height: (24 / @baseSize);
        margin: 0 (24 / @baseSize);
      }
      .launch {
        width: (72 / @baseSize);
        height: (24 / @baseSize);
      }
    }
  }
  .nav {
    position: relative;
    flex: 1;
    height: (40 / @baseSize);
    border-bottom: 1px solid #f4f4f4;
    background-color: #fff;

    ul {
      position: relative;
      display: flex;
      justify-content: space-between;
      padding: 0 (12 / @baseSize) 0 (18 / @baseSize);
      width: 100%;

      li {
       display: flex;

       &:first-child a{
        color: #FB7299;
       }
        a {
          line-height: (40 / @baseSize);
          font-size: (14 / @baseSize);
        }
     }

     .line {
      position: absolute;
      // left: (18 / @baseSize);
      transform: translate(18 / @baseSize);
      bottom: 0;
      width: (28 / @baseSize);
      height: (2 / @baseSize);
      background-color: #FB7299;
     }
    }
    .after {
      position: absolute;
      right: 0;
      top: 0;
      width: (40 / @baseSize);
      height: (40 / @baseSize);
      text-align: center;
      &::after {
        content: '\e6eb';
        line-height: (40 / @baseSize);
        background-color: #fff;
        
      }
    }
  }
}
// 头部结束
// 主体开始
main {
  margin-top: (84 / @baseSize);
  padding: 0 (5 / @baseSize);
  display: flex;
  flex-wrap: wrap;
  .pic {
    padding: (8 / @baseSize) (5 / @baseSize);
    width: 50%;
    a {
  
      .card {

        position: relative;
        width: (172 / @baseSize);
  
        img {
         width: 100%;
        }
        
        .count {
          position: absolute;
          left: 0;
          bottom: 0;
          display: flex;
          justify-content: space-between;
          width: 100%;
          background-image: linear-gradient(transparent, #000);
          padding: (5 / @baseSize) (6 / @baseSize);
          height: (28 / @baseSize);
  
          span {
            font-size: (12 / @baseSize);
            color: #fff;
            &:first-child{ 
              i {
                &::before {
                  content: '\e617';
                }
              }
            }
            &:last-child{ 
              i {
                &::before {
                  content: '\e616';
                }
              }
            }
            
          }
        }
      }
      .title {
        width: 100%;
        margin-top: (6 / @baseSize);
        p {
          font-size: (12 / @baseSize);
        }
      }
    }
  
  
  }

}
// 主体结束
// 输出开始
.openApp{
  width: 100%;
  position: fixed;
  left: 0;
  bottom: (30 / @baseSize);
  .info {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 94%;
    height: (37 / @baseSize);
    margin: 0 auto ;
    border-radius:  (18 / @baseSize);
    background-color: #FB7299;
    color: #fff;
    .logo {
      font-size: (16 / @baseSize);
      margin-right: (15 / @baseSize);
    }
    span {
      font-size: (14 / @baseSize);
    }
  }
}

// 输出结束

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值