仿UC头条首页-html+css+纯JS

本文详细介绍了如何利用HTML5、CSS3以及JavaScript技术,从零开始构建UC头条首页的克隆版。内容涵盖页面布局、响应式设计、动态加载和交互实现等关键点,旨在提升前端开发实战技能。
摘要由CSDN通过智能技术生成

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>仿UC头条</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            font-family: Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,\\5FAE\8F6F\96C5\9ED1,Arial,sans-serif;
            -webkit-appearance: none;
            -moz-appearance: none;
            appearance: none;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }
        body{
            padding-top: 75px;
            color: #333;
        }
        a{
            text-decoration: none;
            color: #333;
        }
        a:hover{
            color: #406599;
        }
        ul{
            list-style: none;
        }
        h3{
            font-weight: normal;
        }
        body>header{
            position: fixed;
            left: 0;
            top: 0;
            width: 100%;
            height: 50px;
            background: orange;
            z-index: 10;
        }
        .top_box{
            position: relative;
            width: 1140px;
            height: 50px;
            margin: 0 auto;
        }
        .top_box>h1{
            font-size: 0;
            position: absolute;
            left: 0;
            bottom: 3px;
            width: 102px;
            height: 44px;
            background: url("img/logo.png") no-repeat;
        }
        .top_box>a{
            position: absolute;
            right: 0;
            height: 50px;
        }
        .top_box>a:hover{
            color: #000;
        }
        .top_box>a>span{
            display: block;
            float: right;
            margin-top: 14px;
        }
        .top_box>a>.icon_down{
            float: left;
            margin-top: 10px;
        }

        .top_box>nav{
            position: absolute;
            top: 75px;
            left: 0;
            width: 140px;
            padding-right: 20px;
        }
        .top_box>nav>ul{
            text-align: center;
        }
        .top_box>nav>ul>li{
            height: 45px;
            line-height: 45px;
            margin-bottom: 2px;
        }
        .top_box>nav>ul>li>a{
            display: block;
            width: 100%;
            height: 100%;
            border: 1px solid transparent;
            border-radius: 4px;
        }
        .top_box>nav>ul>li>a:hover{
            background: orange;
            color: #000;
        }

        .top_box>#sideBox{
            display: none;
            background: #ffffff;
            position: absolute;
            top: 50px;
            right: 0;
            width: 260px;
            height: 500px;
            padding-top: 15px;
        }
        .top_box>#sideBox>#searchBox{
            margin-bottom: 10px;
        }
        .top_box>#sideBox>#erweima{
            background: #f5f5f5;
            padding: 15px 20px;
        }
        .top_box>#sideBox>#erweima img{
            width: 100%;
        }
        main{
            width: 1140px;
            height: 2222px;
            margin: 0 auto;
            padding-left: 140px;
        }

        .content{
            width: 710px;
            float: left;
        }
        .content>ul>li{
            position: relative;
            width: 100%;
            border-bottom: 1px solid #EEEEEE;
        }
        .content img{
            width: 170px;
            height: 109px;
        }
        .content h3{
            line-height: 30px;
            font-size: 20px;
            overflow: hidden;
        }
        .content .info{
            font-size: 14px;
            color: #CCC;
        }
        .content .info>span{
            margin-right: 10px;
        }
        .news_1{
            height: 140px;
        }
        .news_1>a>h3{
            position: absolute;
            left: 190px;
            top: 20px;
            width: 520px;
            height: 60px;
        }
        .news_1>a>img{
            position: absolute;
            left: 0;
            top: 10px;
        }
        .news_1>.info{
            position: absolute;
            left: 190px;
            top: 90px;

        }
        .news_2{
            height: 220px;
        }
        .news_2>a>h3{
            position: absolute;
            left: 0;
            top: 10px;
            width: 710px;
            height: 30px;
        }
        .news_2>a>div.pics{
            position: absolute;
            left: 0;
            top: 50px;
        }
        .news_2>.info{
            position: absolute;
            left: 0;
            top: 170px;
        }
        main>aside{
            width: 260px;
            float: right;
        }
        form{
            position: relative;
        }
        form>input{
            width: 100%;
        
很抱歉,作为AI语言模型,我无法提供图形用户界面。但是,我可以提供示例代码供您参考: <!DOCTYPE html> <html> <head> <title>今日头条</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <header> <h1>今日头条</h1> <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> <li><a href="#">体育</a></li> <li><a href="#">军事</a></li> </ul> </nav> </header> <main> <section class="carousel"> <div class="carousel-item active"> <img src="https://picsum.photos/id/10/640/360" alt="carousel item"> <h2>标题1</h2> <p>这里是描述1</p> </div> <div class="carousel-item"> <img src="https://picsum.photos/id/20/640/360" alt="carousel item"> <h2>标题2</h2> <p>这里是描述2</p> </div> <div class="carousel-item"> <img src="https://picsum.photos/id/30/640/360" alt="carousel item"> <h2>标题3</h2> <p>这里是描述3</p> </div> <div class="carousel-item"> <img src="https://picsum.photos/id/40/640/360" alt="carousel item"> <h2>标题4</h2> <p>这里是描述4</p> </div> <div class="carousel-item"> <img src="https://picsum.photos/id/50/640/360" alt="carousel item"> <h2>标题5</h2> <p>这里是描述5</p> </div> <div class="carousel-item"> <img src="https://picsum.photos/id/60/640/360" alt="carousel item"> <h2>标题6</h2> <p>这里是描述6</p> </div> <div class="carousel-item"> <img src="https://picsum.photos/id/70/640/360" alt="carousel item"> <h2>标题7</h2> <p>这里是描述7</p> </div> <div class="carousel-item"> <img src="https://picsum.photos/id/80/640/360" alt="carousel item"> <h2>标题8</h2> <p>这里是描述8</p> </div> </section> <section class="news"> <h2>热点新闻</h2> <ul> <li> <a href="#"> <img src="https://picsum.photos/id/100/120/80" alt="news item"> <h3>新闻标题1</h3> <p>这里是新闻描述1</p> </a> </li> <li> <a href="#"> <img src="https://picsum.photos/id/110/120/80" alt="news item"> <h3>新闻标题2</h3> <p>这里是新闻描述2</p> </a> </li> <li> <a href="#"> <img src="https://picsum.photos/id/120/120/80" alt="news item"> <h3>新闻标题3</h3> <p>这里是新闻描述3</p> </a> </li> <li> <a href="#"> <img src="https://picsum.photos/id/130/120/80" alt="news item"> <h3>新闻标题4</h3> <p>这里是新闻描述4</p> </a> </li> <li> <a href="#"> <img src="https://picsum.photos/id/140/120/80" alt="news item"> <h3>新闻标题5</h3> <p>这里是新闻描述5</p> </a> </li> </ul> </section> <section class="videos"> <h2>热门视频</h2> <ul> <li> <a href="#"> <img src="https://picsum.photos/id/150/120/80" alt="video item"> <h3>视频标题1</h3> <p>这里是视频描述1</p> </a> </li> <li> <a href="#"> <img src="https://picsum.photos/id/160/120/80" alt="video item"> <h3>视频标题2</h3> <p>这里是视频描述2</p> </a> </li> <li> <a href="#"> <img src="https://picsum.photos/id/170/120/80" alt="video item"> <h3>视频标题3</h3> <p>这里是视频描述3</p> </a> </li> <li> <a href="#"> <img src="https://picsum.photos/id/180/120/80" alt="video item"> <h3>视频标题4</h3> <p>这里是视频描述4</p> </a> </li> <li> <a href="#"> <img src="https://picsum.photos/id/190/120/80" alt="video item"> <h3>视频标题5</h3> <p>这里是视频描述5</p> </a> </li> </ul> </section> </main> <footer> <p>版权所有:今日头条</p> </footer> </body> </html> /* CSS */ * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; background-color: #f5f5f5; color: #333; } header { background-color: #fff; padding: 20px; box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); } header h1 { font-size: 24px; font-weight: bold; margin-bottom: 10px; } nav ul { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; } nav li { margin: 0 10px; } nav a { display: block; padding: 10px; color: #333; text-decoration: none; } nav a:hover { background-color: #f5f5f5; } main { padding: 20px; } .carousel { position: relative; height: 360px; overflow: hidden; margin-bottom: 20px; } .carousel .carousel-item { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.5s ease-in-out; } .carousel .carousel-item.active { opacity: 1; } .carousel img { width: 100%; height: 100%; object-fit: cover; } .carousel h2 { position: absolute; bottom: 20px; left: 20px; font-size: 20px; color: #fff; } .carousel p { position: absolute; bottom: 0; left: 20px; font-size: 14px; color: #fff; } .news, .videos { margin-bottom: 20px; } .news h2, .videos h2 { font-size: 20px; font-weight: bold; margin-bottom: 10px; } .news ul, .videos ul { list-style: none; display: flex; flex-wrap: wrap; justify-content: space-between; } .news li, .videos li { width: calc(50% - 10px); margin-bottom: 10px; background-color: #fff; box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); } .news a, .videos a { display: block; padding: 10px; color: #333; text-decoration: none; } .news a:hover, .videos a:hover { background-color: #f5f5f5; } .news img, .videos img { display: block; margin: 0 auto; max-width: 100%; height: auto; } .news h3, .videos h3 { font-size: 16px; font-weight: bold; margin: 10px 0; } .news p, .videos p { font-size: 14px; margin-bottom: 10px; } footer { background-color: #ddd; padding: 10px; text-align: center; font-size: 12px; }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值