前端学习——css定位

前端学习——css定位

1.学习内容

主要学习css高级运用,掌握更多修饰技巧,增强网页可读性。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>京吃食府2.0</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"><a href="index.html"><img src="images/logo.png"></a> </div>
    <div class="nav">
        <ul>
            <li><a href="./index.html">首页</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="请输入关键字">
        <button></button>
    </div>
    <div class="car">
        <span>2</span>
    </div>
</div>

<!--头下banner图-->
<div class="banner">
<div class="wrapper">
    <ul>
        <li><a href="#"><img src="uploads/food_2.jpg"></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>
        </ul>
    </div>

    <a href="#" class="prev"><</a>
    <a href="#" class="next">></a>

    <ol>
        <li></li>
        <li></li>
        <li class="current"></li>
        <li></li>
        <li></li>
    </ol>
</div>
</div>

<!--版权区域-->
<div class="foot">
    <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>
            </p>
            <p>
                CopyRight @ 京吃食府
            </p>
        </div>
    </div>
</div>

</body>
</html>
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/*去除列表开头标点*/
ul,
ol{
    list-style: none;
}

/*去除超链接下划线*/
a{
    color: #4e4e4e;
    text-decoration: none;
}

/*双伪元素防止浮动错误和避免塌陷*/
.cleafix:before,
.cleafix:after{
    content: "";
    display: table;
}
.cleafix:after{
    clear: both;
}

body{
    font: 16px/1.5 宋体,sans-serif;
    color: #4e4e4e;
    background-color: #f3f5f7;
}

img{
    vertical-align: middle;
}

input{
    border: none;
    outline: none;
    color: #4e4e4e;
}
.wrapper{
    width: 1240px;
    margin: 0 auto;
}

.shortcut{
    height: 52px;
    background-color: #4e4e4e;
}
.shortcut .wrapper{
    height: 52px;
}
.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: #dcdcdcdc;
}
.shortcut .wrapper a span{
    display: inline-block;
    margin-right: 8px;
    height: 20px;
    width: 20px;
    background-image: url("../images/logo-1.jpg");
    background-position: -30px -36px;
    vertical-align: middle;
}
.shortcut .wrapper a:hover{
    color: #000;
}
/*--------------------------------*/
.header{
    margin: 30px auto;
    height: 57px;
}
.logo{
    float: left;
}
.nav{
    float: left;
    margin-left: 70px;
    height: 57px;
}

.nav li{
    float: left;
    margin-right: 60px;
}

.nav li a{
    display: block;
    line-height: 57px;

    font-size: 18px;
    color: black;
}
.nav li a:hover{
    color: grey;
    border-bottom: 2px solid #808080;
}

.search{
    float: left;
    margin-left: 60px;
    width: 462px;
    height: 47px;
    border: 1px solid #808080;
}
.search input{
    float: left;
    padding-left: 20px;
    width: 410px;
    height: 45px;
    border: 0;
    font-size: 18px;
    font-family: 宋体, sans-serif;
}
.search input::placeholder{
    font-size: 16px;
    font-family: 宋体, sans-serif;
    color: #bfbfbf;
}
.search button{
    float: left;
    width: 50px;
    height: 45px;
    background-image: url("../images/search.jpg");
    background-position: 5px 0;
    border: 0;
}

.car{
    position: relative;
    margin: 15px 30px;
    float: right;
    width: 20px;
    height: 20px;
    background-image: url("../images/logo-1.jpg");
    background-position: -198px -260px;
    border-radius: 5px;
}
.car span{
    /*绝对定位,盒子具备行内块特点*/
    position: absolute;
    right: -12px;
    top:-5px;
    width: 15px;
    height: 12px;
    background-color: red;
    border-radius: 8px;
    font-size: 12px;
    color: white;
    text-align: center;
    line-height: 12px;
}

/*------------------------------------------*/

.foot{
    height: 342px;
    background-color: #4e4e4e;
}
.foot .wrapper{
    width: 1393px;
}
 .foot .top{
     padding-top: 60px;
     padding-left: 135px;
     height: 175px;
     border-bottom: 1px solid #cccccc;
 }
 .foot .top li{
     position: relative;
     float: left;
     margin-right: 300px;
     width: 190px;
     height: 40px;
     line-height: 40px;
 }
 .foot .top li:last-child{
     margin-right: 0;
 }
/*伪元素添加标签是行内模式*/
.foot .top li::before{
    position: absolute;
    left: 0;
    top: -5px;
    content: "";
    width: 45px;
    height: 40px;

    background-image: url("../images/logo-0.jpg");
    background-position: -210px -180px;
    vertical-align: middle;
}
.foot .top li span{
    margin-left: 60px;
    font-size: 25px;
    color: white;
}
.foot .top li:nth-child(2)::before{
    background-position: -25px -100px;
}
.foot .top li:nth-child(3)::before{
    background-position: -290px -180px;
}


.foot .bottom{
    margin-top: 40px;
    text-align: center;
    font-size: 14px;
    color: #999;
}
.foot .bottom a{
    font-size: 14px;
    color: #999;
}
.foot .bottom p{
    margin-bottom: 20px;
}
.banner{
    height: 500px;
    background-color: #edeef0;
}
.banner .wrapper{
    position: relative;
    height: 500px;
    background-color: darkolivegreen;
}
.banner .aside{
    position: absolute;
    left: 0;
    top: 0;
    width: 250px;
    height: 500px;
    background-color: rgba(0,0,0,0.5);
}
.banner .aside a{
    display: block;
    margin-top: 55px;
    padding-left: 20px;
    height: 60px;
    line-height: 60px;
    color: white;
    font-size: 20px;
    font-family: "Microsoft YaHei UI";
}
.banner .aside span{
    float: right;
}
.banner .aside a:hover {
    background-color: grey;
}

.prev,
.next{
    position: absolute;
    top: 280px;
    width: 45px;
    height: 45px;
    background-color: rgba(0,0,0,.2);
    border-radius: 50%;
    color: white;
    font-size: 25px;
    font-weight: 800;
    line-height: 45px;
}

.prev{
    left: 260px;
    padding-left: 12px;
}
.next{
    right: 10px;
    padding-left: 15px;
}

.banner ol{
    position: absolute;
    left: 680px;
    bottom: 30px;
    height: 10px;
}
.banner ol li{
    float: left;
    margin-right: 25px;
    width: 10px;
    height: 10px;
    background-color: rgba(255,255,255,0.4);
    border-radius: 50%;
    cursor: pointer;
}
.banner ol .current{
    background-color: white;
}

2.成果展示

在这里插入图片描述
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值