用HTML+CSS做成的一个简单网页(小兔鲜儿)

写在前面的话:在跟着黑马程序员视频学习的时候,做的一个由简单HTML+CSS知识组成的一个简单小网页分享给大家,可以供新手学习。

目录

效果图如下:

HTML相关代码如下:

CSS相关代码如下:

index.css:

common.css:

base.css:

所有资料网盘链接:


效果图如下:

(用到的相关图片是自己随便找的,不太好看,大家可以自行更换)

HTML相关代码如下:

index.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">
    <meta name="description" content="小兔鲜儿官网,致力于打造全球最大的食品、生鲜电商购物平台。">
    <meta name="keywords" content="小兔鲜儿,食品,生鲜,服装,家电,电商,购物">
    <title>小兔鲜儿-新鲜、亲民、快捷</title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <!-- 必须按照这个顺序引用各个样式表 -->
    <link rel="stylesheet" href="./css/base.css">
    <link rel="stylesheet" href="./css/common.css">
    <link rel="stylesheet" href="./css/index.css">
</head> 
<body>
    <!-- 快捷导航 -->
    <div class="shortcut">
        <div class="wrapper">
            <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="#"><span></span>请先登录</a></li>
            </ul>
        </div>
    </div>
    <div class="header wrapper">
        <div class="logo">
            <h1><a href="#">小兔鲜儿</a></h1>
        </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>
                <li><a href="#">首页</a></li>
                <li><a href="#">首页</a></li>
                <li><a href="#">首页</a></li>
            </ul>
        </div>
        <div class="search">
            <input type="text" placeholder="搜一搜">
            <!-- 定位放大镜 -->
            <span></span>
        </div>
        <div class="car">
            <span>2</span>
        </div>
    </div>

    <!-- banner -->
    <div class="banner">
        <div class="wrapper">
            <ul>
                <!-- 有多少个图就有多少个li -->
                <li><a href="#"><img src="./images/图2.jpg" alt=""></a></li>
                <!-- <li><a href="#"><img src="./images/图2.jpg" alt=""></a></li>
                <li><a href="#"><img src="./images/图3.jpg" alt=""></a></li>
                <li><a href="#"><img src="./images/图4.jpg" alt=""></a></li>
                <li><a href="#"><img src="./images/图5.jpg" alt=""></a></li> -->
            </ul>
            <!-- 侧导航 -->
            <div class="aside">
                <ul>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                </ul>
            </div>
            <!-- 箭头 -->
            <!-- prev:上一个 -->
            <div class="prev"></div>
            <!-- next:下一个 -->
            <div class="next"></div>
            <!-- 圆点 :当前状态:current/active-->
            <!-- js 找到用户点击的li 添加类名 li变成白色的 -->
            <ol>
                <li></li>
                <li></li>
                <li class="current"></li>
                <li></li>
                <li></li>
            </ol>
        </div>
    </div>  

    <!-- 新鲜好物 -->
    <div class="goods wrapper">
        <!-- hd 代表header,头部的意思 -->
        <div class="hd">
            <h2>新鲜好物<span>新鲜出炉 品质靠谱</span></h2>
            <a href="#">查看全部<span>></span></a>
        </div>
        <!-- bd 表示body,身体,写内容 -->
        <div class="bd clearfix">
            <ul>
                <li>
                    <a href="#">
                        <img src="./uploads/十二星座手链33.8元.png" alt="">
                        <h3>十二星座手链</h3>
                        <div>¥<span>33.8</span></div>
                        <b>新品</b>
                    </a>
                </li>
                <li>
                    <a href="#">
                        <img src="./uploads/华为手机1588元.png" alt="">
                        <h3>华为手机</h3>
                        <div>¥<span>1588</span></div>
                        <b>新品</b>

                    </a>
                </li>
                <li>
                    <a href="#">
                        <img src="./uploads/海信激光电视10999元.png" alt="">
                        <h3>海信激光电视</h3>
                        <div>¥<span>10999</span></div>
                        <b>新品</b>

                    </a>
                </li>
                <li>
                    <a href="#">
                        <img src="./uploads/瑞士手表1380元.png" alt="">
                        <h3>瑞士手表</h3>
                        <div>¥<span>1380</span></div>
                        <b>新品</b>

                    </a>
                </li>
            </ul>
        </div>
    </div>
    <!-- 生鲜 -->
    <div class="shengxian wrapper">
        <div class="hd">
            <h2>生鲜</h2>
            <a href="#" class="more">查看全部<span>></span></a>
            <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>
            </ul>
        </div>
        <div class="bd clearfix">
            <div class="left">
                <a href="#"><img src="./uploads/手链.png" alt=""></a>
            </div>
            <div class="right">
                <ul>
                    <li><a href="#">
                        <img src="./uploads/华为手机1588元.png" alt="">
                        <div>华为手机<span>1588元</span></div>
                    </a></li>
                    <li><a href="#">
                        <img src="./uploads/华为手机1588元.png" alt="">
                        <div>华为手机<span>1588元</span></div>
                    </a></li>
                    <li><a href="#">
                        <img src="./uploads/华为手机1588元.png" alt="">
                        <div>华为手机<span>1588元</span></div>
                    </a></li>
                    <li><a href="#">
                        <img src="./uploads/华为手机1588元.png" alt="">
                        <div>华为手机<span>1588元</span></div>
                    </a></li>
                    <li><a href="#">
                        <img src="./uploads/华为手机1588元.png" alt="">
                        <div>华为手机<span>1588元</span></div>
                    </a></li>
                    <li><a href="#">
                        <img src="./uploads/华为手机1588元.png" alt="">
                        <div>华为手机<span>1588元</span></div>
                    </a></li>
                    
                </ul>
            </div>
        </div>
    </div>
    <!-- 版权区域 -->
    <div class="footer">
        <div class="wrapper">
            <div class="top">
                <ul>
                    <li>
                        <!-- 通过伪元素添加标签实现精灵图 -->
                        <span>价格亲民</span>
                    </li>
                    <li>
                        <span>物流快捷</span>
                    </li>
                    <li>
                        <span>品质保鲜</span>
                    </li>
                </ul>
            </div>
            <div class="bottom">
                <p>
                    <a href="#">关于我们</a> |
                    <a href="#">关于我们</a> |
                    <a href="#">关于我们</a> |
                    <a href="#">关于我们</a> |
                    <a href="#">关于我们</a> |
                    <a href="#">关于我们</a> |
                    <a href="#">关于我们</a> <br><br>
                CopyRight @ 小兔鲜儿</p>
            </div>
        </div>
    </div>
</body>
</html>

CSS相关代码如下:

index.css:

/* 放index页面的样式表 */
/* banner */
.banner{
    height: 500px;
    background-color: #f5f5f5;
}

.banner .wrapper{
    position: relative;
    height: 500px;
    background-color: pink;
}
/* 侧导航 */
.banner .aside{
    position: absolute;
    left: 0;
    top: 0;
    width: 250px;
    height: 500px;
    background-color: rgba(0,0,0,.8);
}

.banner .aside li{
    height: 50px;
    line-height: 50px;
}

.banner .aside a{
    position: relative;
    /* block会使宽度和父级一样,这样可以省去书写宽度 */
    display: block;
    padding-left: 36px;
    padding-right: 19px;
    height: 50px;
    /* background-color: pink; */

    color: #fff;
}

.banner .aside a span{
    margin-left: 15px;
    font-size: 14px;
}

.banner .aside a:hover{
    background-color: #27ba9b;
}

/* a的里面最后的位置添加箭头 */
.banner .aside a::after{
    position: absolute;
    right: 19px;
    top: 19px;
    content: '';
    width: 16px;
    height: 16px;
    background-image: url(../images/右箭头.png);
    background-size: cover;
}

.prev,.next{
    position: absolute;
    top: 228px;
    width: 45px;
    height: 45px;
    background-color: rgba(0,0,0,.2);
    border-radius: 50%;
}
/* 背景图位置负责两件事:改变箭头在盒子里面的位置;改变精灵图的位置 */
/* 导致在精灵图中测量的尺寸不准确 */
/* 解决方案有两种:
1.书写背景图位置属性,借助谷歌的调试工具调试具体的位置数值
2.书写标签的时候,a负责盒子,里面再添加一个span负责箭头 */
.prev{
    left: 260px;
    background-image: url(../images/箭头左.png);
    background-repeat: no-repeat;
    background-position: 8px 8px;
}

.next{
    right: 10px;
    background-image: url(../images/箭头右.png);
    background-repeat: no-repeat;
    background-position: 9px 8px;
    /* background-size: cover; */
}
/* 圆点 */
.banner ol{
    position: absolute;
    left: 680px;
    bottom: 30px;
    width: 200px;
    height: 10px;
    /* background-color: pink; */
}

.banner ol li{
    float: left;
    margin-right: 24px;
    width: 10px;
    height: 10px;
    background-color: rgba(255,255,255,0.4);
    border-radius: 50%;
    cursor: pointer;
}

.banner ol .current{
    background-color: #fff;
}

/* 新鲜好物 */
.goods .hd{
    height: 114px;
    /* background-color: pink; */
    line-height: 114px;
}

.goods .hd h2{
    float: left;
    height: 114px;
    font-size: 29px;
    font-weight: 400;
}

.goods .hd h2 span{
    margin-left: 34px;
    font-size: 16px;
    color: #999;
}

.goods .hd a,.shengxian .hd .more{
    float: right;
    color: #999;
}

.goods .hd a span,.shengxian .hd .more span{
    float: right;
    display: block;
    width: 7px;
    height: 13px;
    margin-left: 13px;
    color: #999;
}

.goods .bd li{
    position: relative;
    float: left;
    margin-right: 8px;
    width: 304px;
    height: 430px;
    /* background-color: #f0f9f4; */
    text-align: center;
}

.goods .bd li:nth-child(4){
    margin-right: 0;
}

.goods .bd li img{
    width: 304px;
    height: 314px;
    background-size: cover;
}

.goods .bd li h3{
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 20px;
    font-weight: 400;
}

.goods .bd li div{
    color: #9a2e1f;
    font-size: 17px;
}

.goods .bd li div span{
    font-size: 23px;
}

.goods .bd li b{
    position: absolute;
    left: 17px;
    top: 18px;
    width: 28px;
    height: 51px;
    border: 1px solid #27ba9b;
    border-radius: 2px;
    font-size: 18px;
    color: #27ba9b;
    /* font-weight: 400; */
    line-height: 24px;
}

/* 生鲜 */
.shengxian .hd{
    height: 96px;
    /* background-color: pink; */
    line-height: 96px;
}

.shengxian .hd h2{
    float: left;
    font-size: 29px;
    font-weight: 400;
}

.shengxian .hd .more{
    float: right;
}

.shengxian .hd ul{
    float: right;
    margin-right: 65px;
}

.shengxian .hd ul li{
    float: left;
}

.shengxian .hd li a{
    padding: 2px 7px;
    margin-left: 6px;
}

.shengxian .hd li a:hover{
    background-color: #27ba9b;
    color: #fff;
}

.shengxian .bd .left{
        float: left;
        width: 240px;
        height: 610px;
        background-color: pink;
}

.shengxian .bd .right{
    float: right;
    
    width: 990px;
    height: 610px;
    /* background-color: skyblue; */
}

.shengxian .bd .right li{
    float: left;

    margin-left: 10px;
    margin-bottom: 10px;
    width: 320px;
    height: 300px;
    /* background-color: pink; */
}

.shengxian .bd .right li img{
    width: 320px;
    height: 240px;
    background-size: cover;
}
.shengxian .bd .right li div{
    height: 60px;
    font-weight: 700;
    text-align: center;
    line-height: 60px;
    color: #999;
}

.shengxian .bd .right li span{
    color: pink;
}

common.css:

/* 各个页面相同的样式表:头,尾部 */
/* 版心 */
.wrapper{
    width: 1240px;
    margin: 0 auto;
}
/* 快捷导航 */
.shortcut{
    height: 52px;
    background-color: #333;
}
.shortcut .wrapper{
    height: 52px;
    /* background-color: pink; */
}
.shortcut .wrapper ul{
    float: right;
}
.shortcut .wrapper li{
    float: left;
    line-height: 52px;
}
.shortcut .wrapper a{
    padding: 0 16px;
    border-right:1px solid #666 ;
    font-size: 14px;
    color: #dcdcdc;
}
.shortcut .wrapper a span{
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    background-image:url(../images/手机\ .ico) ;
    vertical-align: middle;
}
/* 清除a的边框线,最后一个li里面的a */
.shortcut .wrapper li:last-child a{
    border: 0;
}
/* 头部 */
.header{
    margin: 30px auto;
    height: 70px;
}

.logo{
    float: left;
    width: 207px;
    height: 70px;
    /* background-color: pink; */
}
/* logo搜索引擎优化做法 */
.logo h1{
    width: 207px;
    height: 70px;
}
.logo h1 a{
    display: block;
    width: 207px;
    height: 70px;
    background-image: url(../images/logo.png);
    background-size: contain;
    font-size: 0;
}

.nav{
    float: left;
    margin-left: 40px;
    height: 70px;
    /* background-color: pink; */
}

.nav li{
    float: left;
    line-height: 70px;
    margin-right: 48px;
}
.nav li a{
    padding-bottom: 7px;
}

.nav li a:hover{
    color: green;
    padding-bottom: 7px;
    border-bottom: 1px solid green;
}

.search{
    position: relative;
    float: left;
    margin-left: 34px;
    margin-top: 24px;
    width: 172px;
    height: 30px;
    /* background-color: green; */
    border-bottom: 2px solid #e7e7e7;
}

.search input{
    padding-left: 30px;
    width: 172px;
    height: 28px;
}

.search input::placeholder{
    font-size: 14px;
    color: #ccc;
}

.search span{
    position: absolute;
    left: 2px;
    top: 0;
    display: inline-block;
    width: 18px;
    height: 18px;
    /* background-color: pink; */
    background-image: url(../images/搜索\ .png);
    background-size: cover;
}

.car{
    position: relative;
    float: left;
    margin-top: 28px;
    margin-left: 15px;
    width: 23px;
    height: 23px;
    /* background-color: skyblue; */
    background-image: url(../images/购物车空.png);
    background-size: cover;
}

.car span{
    /* 绝对定位,盒子具备行内块特点 */
    position: absolute;
    right: -13px;
    top: -6px;
    width: 20px;
    height: 15px;
    background-color: #e26237;
    border-radius: 8px;

    font-size: 13px;
    color: #fff;
    text-align: center;
    line-height: 15px;
}

/* 版权footer */
.footer{
    height: 342px;
    background-color: #333;
}

.footer .wrapper{
    width: 1393px;
}

.footer .top{
    height: 175px;
    padding-top: 59px;
    padding-left: 50px;
    border-bottom: 1px solid #434343;
}

.footer .top li{
    position: relative;
    float: left;
    margin-right: 280px;
    width: 195px;
    height: 58px;
    /* background-color: pink; */
}

.footer .top li:last-child{
    margin-right: 0;
}
/* 伪元素添加的标签,行内 */
/* 如果行内块和行内文字无法通过vertical-align或行高对齐,则使用定位的方法 */
.footer .top li::before{
    position: absolute;
    left: 0;
    top: 0;
    /* display: inline-block; */
    content: '';
    width: 58px;
    height: 58px;
    background-image: url(../images/价格亲民.png);
    background-size:cover;
    vertical-align: middle;
    
}

.footer .top li span{
    margin-left: 77px;
    font-size: 28px;
    color: #fff;
    line-height: 58px;
}

/* 第二个li里面的before添加背景图位置属性 */
.footer .top li:nth-child(2)::before{
    background-image: url(../images/物流.png);
    background-size:cover;
}
.footer .top li:nth-child(3)::before{
    background-image: url(../images/品质新鲜.png);
    background-size: cover;
}

.footer .bottom p{
    padding-top: 40px;
    text-align: center;
    font-size: 14px;
    color: #999;
}

.footer .bottom a{
    font-size: 14px;
    color: #999;
}

base.css:

/* 清楚默认样式的代码 */

/* 去除常见标签默认的margin和padding */
body,h1,h2,h3,h4,h5,h6,p,ul,ol,li,dl,dt,dd,
input {
margin: 0 ;padding: 0;
}
/* 内减模式 */
*{
    box-sizing: border-box;
}

/* 设置网页统一的字体大小,行高,字体系列相关属性 */
body {
    font: 16px/1.5 "Helvetica Neue",Helvetica,Arial,"MicrosoftYahei","Hiragino Sans GB","Heiti sC","WenQuanYi Micro Hei",sans-serif ;
    color: #333;
}
    
/* 去除列表默认样式 */
ul,ol {
    list-style: none;
    }

/* 去除默认的倾斜效果 */
em,i {
    font-style: normal ;
    }

/* 去除a标签默认下划线,并设置默认文本颜色 */
a{
    text-decoration: none;
    color: #333;
}
    
/* 设置img的垂直对齐方式为居中对齐,去除img默认下间隙 */
img{
    vertical-align: middle;
}

/* 去除input默认样式 */
input {
    border: none ;
    outline: none;
    color : #333;
    }

/* 左浮动 */
.fl{
    float: left;
}

/* 右浮动 */
.fr{
    float: right;
}

/* 双伪元素清除法 */
.clearfix::before,.clearfix::after{
    content: '';
    display: table;
    }
.clearfix::after {
    clear: both;
    }


    
    

所有资料网盘链接:

链接:https://pan.baidu.com/s/1aQiv_0gWDLpMuMnuYhDWXw 
提取码:yyjy

  • 27
    点赞
  • 206
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值