CSS 定位盒子居中对齐

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>

        * {
            margin: 0;
            padding: 0;
        }

        div {
            width: 520px;
            height: 280px;
            margin: 20px auto;
            position: relative;
        }

        .leftDot {
            width: 24px;
            height: 36px;
            position: absolute;
            top: 50%;
            margin-top: -18px;
            background: url("images/left.png") no-repeat;
        }

        .rightDot {
            width: 24px;
            height: 36px;
            position: absolute;
            right: 0;
            top: 50%;
            margin-top: -18px;
            background: url("images/right.png") no-repeat;
        }


        ul {
            width: 70px;
            height: 14px;
            background-color: rgba(255,255,255,0.5);
            border-radius: 8px;
            position: absolute;
            bottom: 20px;
            left: 50%;
            margin-left: -35px;
        }

        li {
            float: left;
            list-style: none;
            width: 8px;
            height: 8px;
            border-radius: 4px;
            background-color: white;
            margin: 3px;
            display: inline-block;
        }
    </style>
</head>
<body>
    <div>
        <img src="images/taobao.jpg" height="280" width="520"/>
        <a href="#" class="leftDot"></a>
        <a href="#" class="rightDot"></a>
        <div class="bottomDot"></div>
        <ul>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .sf {
            width: 1259px;
            height: 472px;
            margin: 0 auto;
            position: relative;
        }

        .nav {
            width: 960px;
            height: 80px;
            background-color: #000;
            position: absolute;
            bottom: 0;
            left: 50%;
            margin-left: -480px;
        }

        .nav li {
            float: left;
            width: 160px;
            height: 80px;
            list-style: none;
            line-height: 80px;
        }

        .nav li a {
            text-align: center;
            text-decoration: none;
            display: block;
            color: white;
        }

        .nav li a:hover {
            color: #000;
            background-color: #fff;
        }
    </style>
</head>
<body>
    <div class="sf">
        <a href="#">
            <img src="images/sf.png" height="472" width="1259"/>
        </a>

        <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>
            </ul>
        </div>
    </div>
</body>
</html>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容