简体   繁体   English

Google Chrome中奇怪的额外DIV高度

[英]Strange extra DIV height in Google Chrome

I have two DIVs: 我有两个DIV:

  • first one is narrow and is floated left and displays a kind of vertical tab structure. 第一个是狭窄的并且向左浮动并且显示一种垂直标签结构。
  • second one displays content per selected item in the left DIV 第二个显示左侧DIV中每个所选项目的内容

You can see a simplified example here on JSFiddle . 你可以在JSFiddle上看到一个简化的例子。

As shown in example, left DIV is usually higher than the right one. 如示例所示,左DIV通常高于右DIV。 That's why the right DIV is vertically shifted down to align it to the bottom of the selected item in the left DIV so the content is always in view when a user selects an item on the left. 这就是为什么右侧DIV垂直向下移动以使其与左侧DIV中所选项目的底部对齐,因此当用户选择左侧的项目时,内容始终处于视图中

Everything works as expected in Firefox and IE but not in Chrome. 一切都在Firefox和IE中按预期工作,但在Chrome中没有。

Chrome issue Chrome问题

Whenever you select an item in the left DIV that should reposition the right DIV, the whole container of both gets higher even though non of the contained DIVs is as heigh. 每当你在左侧DIV中选择一个应该重新定位右侧DIV的项目时,即使所包含的DIV没有高度,两者的整个容器也会变高。

What seems to be going on here and what am I doing wrong? 这里似乎发生了什么,我做错了什么?

You can hide the extra height that is added by using .container { overflow-y: hidden; } 您可以使用.container { overflow-y: hidden; }添加的额外高度.container { overflow-y: hidden; } .container { overflow-y: hidden; }

将右侧div容器设置为position:absolute(即右侧和左侧容器的高度相同,设置宽度为您自己的容器)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM