35displayinline-block的上下对齐方式

1、盒子里有内容时,是内容顶部与内容顶部对齐,有border-top或margin-top时,border-top或margin-top凸出在对齐线上面。
2、盒子里无内容时,是margin-bottom底部与margin-bottom底部对齐;无border-bottom和margin-bottom时,内容的底部与margin-bottom的底部对齐;有border-bottom且无margin-bottom时,border-bottom的底部与margin-bottom的底部对齐。
3、有的盒子有内容,有的盒子没内容,有内容盒子的内容底部与无内容盒子的margin-bottom的底部对齐。
4、示例如下:
```html:run
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
*{padding:0;margin:0;}
</style>
</head>
<body>
<div style="display: inline-block;height:50px;width:100px;background:red;">0</div>
<div style="display: inline-block;height:40px;width:100px;background:red;border-top:25px solid green;">0</div>
<div style="display: inline-block;height:60px;width:100px;background:red;border-top:25px solid green;margin-top:30px;">0</div>


<div style="display: inline-block;height:50px;width:100px;background:red;"></div>
<div style="display: inline-block;height:40px;width:100px;background:red;border-bottom:25px solid green;"></div>
<div style="display: inline-block;height:60px;width:100px;background:red;border-bottom:25px solid green;margin-bottom:30px"></div>
</body>
</html>
```

转载于:https://www.cnblogs.com/gushixianqiancheng/p/10966658.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值