<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-sacle=1,user-scalable=no">
<style>
*{
padding: ;
margin: ;
}
.test{
width: 102px;
margin-top: 100px;
margin-left: 100px;
}
.test ul{
overflow: hidden;
}
.test ul li{
/*display: block;*/
float: left;
border: 1px solid #;
}
.test1{
display: block;
width: 100px;
height: 50px;
line-height: 50px;
background-color: red;
overflow: hidden;
}
.test1 p{
float: left;
}
</style>
</head>
<body>
<div class="test">
<ul>
<li>
<div class="test1">
<p>我发的是</p>
</div>
</li>
</ul>
</div>
</body>
</html>

给li里面的div设置overflow: hidden就会西湖此案这个问题

如果去掉overflow: hidden或者给li设置display:block或者display:inline-block就正常,不懂为什么

下面这个是网上找到的,但是和我遇到的问题还是有差距

转:https://my.oschina.net/u/214483/blog/663133

工作中遇到的一个问题,设置inline-block元素的overflow:hidden意外增加元素总体高度。

描述如下:

设 A为子容器,B为父容器。

A设置为inline-block,并且overflow为hidden,A高度为23,B高度为30。

A设置为block,A高度为23,B高度为23。

通过stackoverflow找到原因(http://stackoverflow.com/questions/22421782/css-overflow-hidden-increases-height-of-container),摘抄如下:

Let me explain to you why this is happening.

According to CSS 2.1 Specs,

The baseline of an 'inline-block' is the baseline of its last line box in the normal flow, unless it has either no in-flow line boxes or if its 'overflow' property has a computed value other than 'visible', in which case the baseline is the bottom margin edge.

To explain in simple words,

i) If inline-block in question has its overflow property set to visible (which is by default so no need to set though). Then its baseline would be the baseline of the containing block of the line. ii) If inline-block in question has its overflow property set to OTHER THAN visible. Then its bottom margin would be on the baseline of the line of containing box.

So, in your case the inline-block cell has overflow:hidden (not VISIBLE), so its margin-bottom, the border of cell is at the baseline of the container element container.

That is why the element cell looks pushed upwards and the height of container appears increased. You can avoid that by setting cell to display:block.

翻译如下:

'inline-block'的baseline是其在normal flow中的最后一个line box的baseline,除非它没有in-flow line boxes,或者其‘overflow’属性不等于‘visible’,这种情况下,其baseline位于bottom margin边上。

解释如下:

i) 如果inline-block的overflow设为visible(默认属性),则其baseline是当前行的containing block的baseline。

ii) 如果overflow设为其他,则其bottom margin位于前行的containing block的baseline;

我们这种情况下,inline-block元素的overlow:hidden,所以元素的底部边框在父元素的baseline。

因此高度才会看起来增加了。

可以将inline-block设为block,即可解决问题。

最新文章

  1. 2011奥斯卡最佳纪录片《监守自盗(Inside Job)》小结
  2. enum 与 enum class
  3. Object-c 内存管理
  4. listview优化技术
  5. 关闭和开启oracle
  6. Java_Swing实现小球沿正弦曲线运动的代码
  7. 面试题_103_to_124_关于 OOP 和设计模式的面试题
  8. 理解Java NIO
  9. media screen 响应式布局(知识点)
  10. Computer Graphics Thinking–texture tiling
  11. WORD-如何解除WORD文档的锁定
  12. webstrom 常用快捷键
  13. C++内置类型对象之间的转换
  14. JS组件系列——基于Bootstrap Ace模板的菜单Tab页效果优化
  15. MySQL多数据源笔记1-MySQL主从复制
  16. idea代码提示,不区分大小写
  17. MYSQL总览
  18. 解放F5——React开启模块热更新
  19. 一款我常用到的手机app
  20. 20个实用的webApp前端开发技巧

热门文章

  1. [转帖]SSL/TLS/WTLS原理
  2. linux 文件夹操作
  3. java之常量折叠
  4. CUDA ---- 线程配置
  5. 【转】fiddler抓包时出现了tunnel to ......443 解密HTTPS数据
  6. MySQL relay_log_purge=0 时的风险
  7. 获取androdmanifest里面的meta-data
  8. NetBeans无法使用svn相关功能
  9. 【Luogu P4149】[IOI2011]Race(点分治)
  10. 《剑指offer》— JavaScript(34)第一个只出现一次的字符