博主信息
博文 64
粉丝 2
评论 3
访问量 89518
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
四钟对齐方式
清雨的博客
原创
1109人浏览过

效果图:1.png

代码实例

实例

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>四种对齐方式</title>
    <style type="text/css">
    .box {
        width: 600px;
        /*设置宽度。*/
        height: 300px;
        /*设置高度。*/
        margin: auto;
        /*设置水平居中。*/
        background-image: url(image/1.jpeg);
        /*添加背景图片。*/
        background-repeat: no-repeat;
        /*背景图像将仅显示一次。*/
        /*把背景图像扩展至足够大,以使背景图像完全覆盖背景区域。*/
        background-size: cover;
    }

    .box-box {
        width: 600px;
        height: 260px;
    }

    .box1 {
        width: 199px;
        height: 260px;
        border-right-style: solid;
        border-width: 1px;
        border-right-color: #999999;
        float: left;
    }

    .box2 {
        text-align: center;
        /*可以使内部行内元素水平居中*/
        height: 39px;
        line-height: 39px;
        /*子元素设置行高与父元素高度相同*/
        border-bottom-style: solid;
        border-width: 1px;
        border-bottom-color: #999999;
    }

    .box2 h3 {
        margin: 0;
    }

    .box3 {
        width: 200px;
        height: 219px;
        text-align: center;
        /*可以使内部行内元素水平居中*/
        display: table-cell;
        /*设置显示方式为表格单元格*/
        vertical-align: middle;
        /*设置该单元格内的元素垂直居中*/
        border-bottom-style: solid;
        border-width: 1px;
        border-bottom-color: #999999;
    }

    .box3 li {
        list-style: none;
        /*display: inline;*/
        line-height: 40px;
    }

    .box4 {
        width: 400px;
        height: 259px;

        border-bottom-style: solid;
        border-width: 1px;
        border-bottom-color: #999999;
        display: table-cell;
        /*设置显示方式为表格单元格*/
        vertical-align: middle;
        /*设置该单元格内的元素垂直居中*/
    }

    #box5 {

        width: 600px;
        height: 39px;
        text-align: center;
        /*使行内元素水平居中*/
        display: table-cell;
        vertical-align: bottom;
        /*设置单元格内元素进行底部居中*/
    }

    #box5 ul {
        margin: 0;
        padding: 0;
    }

    #box5 li {
        list-style: none;
        display: initial;
        /*默认。此元素会被显示为内联元素,元素前后没有换行符。*/
        color: red;
    }

    .meng {
        width: 100px;
        height: 100px;
        margin: auto;
        /*水平居中*/
    }

    .meng img {
        width: 100px;
        height: 100px;
    }
    </style>
</head>

<body>
    <div class="box">
        <div class="box-box">
            <div class="box1">
                <div class="box2">
                    <h3>登鹳雀楼</h3>
                </div>
                <div class="box3">
                    <li>白日依山尽,</li>
                    <li>黄河入海流。</li>
                    <li>欲穷千里目,</li>
                    <li>更上一层楼。</li>
                </div>
            </div>
            <div class="box3">
                <div class="box4">
                    <img src="image/2.jpg">
                </div>
            </div>
        </div>
        <div id="box5">
            <ul>
                <li>1</li>
                <li>2</li>
                <li>3</li>
                <li>4</li>
                <li>5</li>
                <li>6</li>
                <li>7</li>
                <li>8</li>
                <li>9</li>
                <li>10</li>
            </ul>
        </div>
    </div>
</body>
</html>

运行实例 »

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

手抄作业:

149031790403069968.jpg

235247548086940074.jpg

批改状态:合格

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

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

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