博主信息
博文 17
粉丝 0
评论 0
访问量 14964
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
元素对齐与盒子定位--2018-08-17 12:00
Aken的博客
原创
970人浏览过

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>定位实现十字架</title>
    <style>
        body{
            margin: 0;
            padding: 0;
        }
        .z{
            position: relative;
        }
        .div1{
            width: 100px;
            height: 100px;
            background:lightskyblue;
            position: absolute;
            left: 100px;
            top: 0px;
        }
        .div2{
            width: 100px;
            height: 100px;
            background:lightblue;
            position: absolute;
            top: 100px;
            left: 0px;
        }
        .div3{
            width: 100px;
            height: 100px;
            background:lightcoral;
            position: absolute;
            left: 200px;
            top: 100px;
        }
        .div4{
            width: 100px;
            height: 100px;
            background: lightcyan;
            position: absolute;
            top: 200px;
            left: 100px;
        }
    </style>
</head>
<body>
<div class="z">
    <div class="div1"></div>
    <div class="div2"></div>
    <div class="div3"></div>
    <div class="div4"></div>
</div>

</body>
</html>

运行实例 »

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

QQ图片20180817112530.png


实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>元素对齐方式</title>
    <style>
        .div1{
            width: 100px;
            height: 100px;
            background: lightblue;
            line-height: 100px;
            text-align: center;
        }
        .div2{
            width: 150px;
            height: 150px;
            background: lightcyan;
            text-align: center;
        }
        .div2 p{
            margin: 0;
            line-height: 150px;
        }
        .div3{
            width: 200px;
            height: 200px;
            background: lightseagreen;
            text-align: center;
            display: table-cell;
            vertical-align: middle;
        }
        .div4{
            width: 200px;
            height: 200px;
            background: lightpink;
            text-align: center;
            display: table-cell;
            vertical-align: middle;
        }
        .div4 p{
            margin: 0;
        }
    </style>
</head>
<body>

<div class="div1">div1内容</div>
<div class="div2"><p>div2内容</p></div>
<div class="div3"><a href="#">aaa</a><span>spanspan</span></div>
<div class="div4"><p>p</p></div>

</body>
</html>

运行实例 »

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


QQ图片20180817112639.png

批改状态:合格

老师批语:缺少手写代码!
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学