博主信息
博文 60
粉丝 0
评论 1
访问量 46050
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
3月23日非作业2
威灵仙的博客
原创
879人浏览过

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对齐的练习</title>
    <style type="text/css">
        *{margin: 0; padding: 0; list-style: none; text-decoration: none;}
        .box{
            width: 600px;
            height:320px;
            border:1px solid #eee;
            border-radius: 20px;
            box-shadow:0 0 10px rgba(0,0,0,0.2);
            background-image: url(..images/jx.png);
            background-repeat: no-repeat;
            background-size: auto 100%;
            background-position: top center;
            margin: 50px auto;

        }
        .box .left{
            float:left;
            width: 239px;
            height: 280px;
            border-right: 1px solid #aaa;
        }
        .box .left .title{
            /*父级块元素,子级内联元素,父元素设置text-align:center水平居中,line-height与高度等高垂直居中*/
            font-size: 24px;
            height: 50px;
            line-height: 50px;
            text-align: center;
            border-bottom: 1px solid #aaa;
            font-weight: bold;
        }
        .box .left .content{
            /*父级块元素,子级多行内联元素,父元素设置text-align:center水平居中,父元素设置:display:table-cell;vertical-align:middle垂直居中*/
            width:240px;
            height: 227px;
            line-height: 48px;
            color:green;
            display: table-cell;  /*设置显示方式为表格单元格*/
            vertical-align: middle;
            text-align: center;
            border-bottom: 1px solid #aaa;
        }
        .right{
            float: right;

        }
        .right .box2{
            /*父级块元素,子级也是块元素,子元素设置margin: auto;水平居中,父元素设置:display:table-cell;vertical-align:middle垂直居中*/
            width: 360px;
            height: 278px;
            border-bottom: 1px solid #aaa;
            display: table-cell;
            vertical-align: middle;
        }
        .right .box2 img{
            display: block;
            width: 300px;
            height: 200px;
            margin:auto;
        }

        .box .page{
            /*子元素是不定宽的块元素,子元素转行内元素,父元素设置text-align:center水平居中,父级设置vertical-align:bottom底边居中*/
            width: 100%;
            height: 40px;
            display: table-cell;
            vertical-align: bottom;
            text-align: center;
        }
        .box .page li{
            display: inline;
            border:1px solid #bbb;
            padding: 2px;
        }

    </style>
</head>
<body>
    <div class="box">
        <div class="left">
            <div class="title"><span>诗一首</span></div>
            <div class="content">
                <span>离离原上草</span><br>
                <span>一岁一枯荣</span><br>
                <span>野火烧不尽</span><br>
                <span>春风吹又生</span>
            </div>
        </div>
        <div class="right">
            <div class="box2">
                <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1521998580610&di=e036cef87eab2658fc1d90183c556d83&imgtype=0&src=http%3A%2F%2Fs4.sinaimg.cn%2Fbmiddle%2F4f1cdb9b4438208d3cb53"" alt="这是一张转换成block的图,尺寸为300*200">
            </div>
        </div>
        <div class="page">
            <ul>
                <li><a href="">1</a></li>
                <li><a href="">2</a></li>
                <li><a href="">3</a></li>
                <li><a href="">4</a></li>
                <li><a href="">5</a></li>
            </ul>
        </div>

    </div>
</body>
</html>

运行实例 »

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


批改状态:合格

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系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+教程免费学