美文网首页Html+Css
CSS 定位盒子居中对齐

CSS 定位盒子居中对齐

作者: roy_pub | 来源:发表于2018-12-11 21:06 被阅读21次
<!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>

相关文章

  • CSS 定位盒子居中对齐

  • CSS基础第五天

    1、定位的盒子居中显示 ★:margin:0 auto; 只能让标准流的盒子居中对齐。★定位的盒子居中:先左右走...

  • 一些小技巧

    1、定位的盒子水平/垂直居中对齐的完美写法 之前让我们定位的盒子水平居中对齐的写法是这样子的水平居中:left:5...

  • css_10 定位盒子居中

    ★:margin:0 auto; 只能让标准流的盒子居中对齐。 ★定位的盒子居中:先向右走父元素盒子的一半50%...

  • CSS3 2D变形

    利用 transform 使定位盒子居中对齐 转换是CSS3中具有颠覆性的特征之一,可以实现元素的位移、旋转、变形...

  • 前端学习day4-总结

    关键词:CSS伪元素before after ,盒子里面元素居中对齐的两种方法,flex弹性布局 ...

  • 【CSS】面试题

    介绍一下css盒子模型? 标准盒子 IE盒子(怪异盒子) flex弹性盒子 多列布局 盒子水平居中 定位:3种 d...

  • html编程技巧

    字体外部描边 Css 基于flex布局的盒子上下居中 Css 基于flex布局的盒子左右居中 Css 基于flex...

  • 傻瓜式 前端代码 生成器

    CSS 居中对齐 http://howtocenterincss.com/ CSS 网格 https://cssg...

  • css基础理论(对齐,组合选择符,伪类,伪元素,导航栏,下拉菜单

    CSS 布局 - 水平 & 垂直对齐 元素居中对齐 要水平居中对齐一个元素(如 ), 可以使用margin: au...

网友评论

    本文标题:CSS 定位盒子居中对齐

    本文链接:https://www.haomeiwen.com/subject/ucsjhqtx.html