不确定高度的内容能相对左邻右舍和父元素垂直居中提供一个思路

<!DOCTYPE html>
<html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>不确定高度的内容能相对左邻右舍和父元素垂直居中提供一个思路</title>
        <style type="text/css">
            .section{
                width: 100%;
                overflow: hidden;
                font-size: 0;  /*这里为0是因为子元素inline-block 之间可能有空格*/
                background-color: #eee;
            }
            .picture{
                width: 33.333%;
                vertical-align: middle;
                display: inline-block;  /*float 就是block布局 vertical-align不起作用*/
            }
            .picture img{
                width: 100%;
            }
            .text{
                width: 33.333%;
                vertical-align: middle; /*两个都要加*/
                display: inline-block;
                padding: 0 20px;
                box-sizing: border-box;
                background-color: #ccc;
            }
            .text h2{
                font-size: 20px;
                line-height: 48px;
                margin: 0;
            }
            .text p{
                font-size: 14px;
                line-height: 22px;
                margin: 0;  /*谷歌的-webkit-margin-after 和 -webkit-margin-before很友(tao)好(yan)呀*/
            }
        </style>
    </head>

    <body>
        <div class="section">
            <div class="picture"><img src="http://sucai.epweike.com/uploadfile/2014/0210/thumb_500_332_20140126114608129.jpg" alt="" /></div>
            <div class="text">
                <h2>DIV CLASS=TEXT</h2>
                <p>这里是一个<strong>字数长度不确定</strong>的段落,到底有多少个字我也不知道,有几行我也不清楚,高度是随意的,但是我依然希望他能相对于图片垂直剧中,随时修改文字都可以。但是高度还是不要大于左右两个图片的高度吧,否则也没意义呀。ps:图片来源于网络</p>
            </div>
<!--左右都有-->
<div class="picture"><img src="http://sucai.epweike.com/uploadfile/2014/0210/thumb_500_332_20140126114608129.jpg" alt="" /></div>
        </div>
    </body>

</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值