博客列表 >0705相对定位与绝对定位的区别与联系

0705相对定位与绝对定位的区别与联系

Yx的博客
Yx的博客原创
2019年07月07日 19:21:43829浏览

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style type="text/css">
        .parent {
            position: relative;
            border: 1px dashed gray;
            width: 450px;
            height: 450px;

        }

        .box1 {
            width: 150px;
            height: 150px;
            background-color: lightblue;
            border-radius: 50%;
        }

        .box2 {
            width: 150px;
            height: 150px;
            background-color: lightgray;
            border-radius: 50%;
        }

        .box3 {
            width: 150px;
            height: 150px;
            background-color: lightgreen;
            border-radius: 50%;
        }

        .box4 {
            width: 150px;
            height: 150px;
            background-color: lightcoral;
            border-radius: 50%;
        }

        .box5 {
            width: 150px;
            height: 150px;
            background-color: lightseagreen;
            border-radius: 50%;
        }

        .box1 {
            position: absolute;
            left: 150px;
            border-radius: 50%;
        }

        .box2 {
            position: absolute;
            top: 150px;
            border-radius: 50%;
        }

        .box3 {
            position: absolute;
            left: 300px;
            top: 150px;
            border-radius: 50%;
        }

        .box4 {
            position: absolute;
            left: 150px;
            top: 150px;
            border-radius: 50%;
        }

        .box5 {
            position: absolute;
            left: 150px;
            top: 300px;
            border-radius: 50%;
        }
    </style>
    <title>20190705作业,绝对定位小案例(</title>
</head>
<body>

    <div class="parent">
        <div class="box1"></div>
        <div class="box2"></div>
        <div class="box3"></div>
        <div class="box4"></div>
        <div class="box5"></div>
    </div>

</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

 

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议