移动端项目:足球圈 部分代码

HTML + CSS + LESS + JS

部分示例代码如下:

JS代码:

   /*函数 :为了完成某个功能的代码块,可以理解就是一个功能 */
        /*fn这个函数是为完成 js动态计算不同屏幕html的font-size*/
        function fn(){
            /*desw存着设计稿的宽是750*/
            var desW = 640;
            /*js获取屏幕的宽存在了winW*/
            var winW = document.documentElement.clientWidth || document.body.clientWidth;
            /*如果屏幕大于设置稿的宽,我让屏幕的宽等于设计稿的宽*/
            if(winW > desW){
                winW = desW;
            }
            /*计算html的font-size*/
            var rate = winW / desW * 100;

            /*给html设置font-size*/
            document.documentElement.style.fontSize = rate + "px";
        }

        fn();
        //屏幕只要切换尺寸,能自动执行fn这个函数 
        window.addEventListener('resize',fn);
  

LESS代码:

@import "reset.css";
@import "../font/iconfont.css";
*{
    margin: 0;
    padding: 0;
}
html,body{
    height: 100%;
}
body{
    max-width: 6.4rem;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}
header{
    height: 0.88rem;
    background-color: #0dc441;
    display: flex;
    justify-content: center;
    align-items: center;
    a{
        width: 1.22rem;
        height: 0.48rem;
        font-size: 0.24rem;
        color: #a3e9b7;
        text-decoration: none;
        text-align: center;
        line-height: 0.48rem;
        background-color: #3dd067;
        &:nth-child(1){
            border-radius: 0.3rem 0 0 0.3rem;
        }
        &:nth-child(2){
            border-radius: 0 0.3rem 0.3rem 0 ;
        }
        &.cur{
            background-color: #64d985;
            color: #fff;
        }
    }
}
nav{
    height: 0.7rem;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    a{
        color: #666;
        font-size: 0.28rem;
        text-align: center;
        line-height: 0.7rem;
        flex: 1;
        &.click{
            color: #0dc441;
            border-bottom: 0.05rem solid #0dc441;
            box-sizing: border-box;
        }
    }
}
main{
    overflow: auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    flex: 1;
    div{
        width: 49%;
        border: 1px solid #e5e5e5;
        margin-top: 0.08rem;
        img{
            width: 100%;
        }
        p{
            height: 0.58rem;
            line-height: 0.58rem;
            font-size: 0.24rem;
            color: #333;
            border-top: 1px solid #e5e5e5;
            padding-left: 0.2rem;
        }
    }
}
footer{
    height: 0.86rem;
    font-size: 0.24rem;
    color: #c7c3c3;
    padding: 0 .23rem 0 .3rem;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .iconfont{
        font-size: 0.5rem;
    }
    p{
        font-size: 0.24rem;
    }
    .cur{
        color: #0dc441;
    }
    .rel{
        width: 1.04rem;
        height: 0.87rem;
        position: relative;
        img{
            width: 100%;
            position: absolute;
            left: 0;
            bottom: 0;
        }
    }
}

HTML代码: 

<body>
    <!-- 头部 -->
    <header>
        <a href="#" class="cur">热点</a>
        <a href="#">关注</a>
    </header>
    <!-- 导航 -->
    <nav>
        <a href="#" class="click">足球现场</a>
        <a href="#">足球生活</a>
        <a href="#">足球美女</a>
    </nav>
    <!-- 主体 -->
    <main>
       <div>
           <img src="images/pic_03.jpg" alt="">
           <p>小丸子啊萌萌哒小丸...</p>
       </div>
       <div>
           <img src="images/pic_03.jpg" alt="">
           <p>小丸子啊萌萌哒小丸...</p>
       </div>
       <div>
           <img src="images/pic_03.jpg" alt="">
           <p>小丸子啊萌萌哒小丸...</p>
       </div>
       <div>
           <img src="images/pic_03.jpg" alt="">
           <p>小丸子啊萌萌哒小丸...</p>
       </div>
       <div>
           <img src="images/pic_03.jpg" alt="">
           <p>小丸子啊萌萌哒小丸...</p>
       </div>
       <div>
           <img src="images/pic_03.jpg" alt="">
           <p>小丸子啊萌萌哒小丸...</p>
       </div>
    </main>
    <!-- footer -->
    <footer>
        <div class="iconfont cur">
            &#xe650;
            <p>首页</p>
        </div>
        <div class="iconfont">
            &#xe62d;
            <p>发现</p>
        </div>
        <div class="rel">
            <img src="images/zxj_03.png" alt="">
        </div>
        <div class="iconfont">
            &#xe620;
            <p>我的</p>
        </div>
        <div class="iconfont">
            &#xe603;
            <p>退出</p>
        </div>
    </footer>
</body>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

一只大菜鸟J

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

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

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

打赏作者

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

抵扣说明:

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

余额充值