简体   繁体   English

div未在显示中填充空格:table;

[英]divs not filling white-space in display: table;

I have created a slideshow and to the right of it there are divs, they will be enlarged when you hover over them and when you take your cursor off the div it will shrink. 我创建了一个幻灯片,在它的右边有div,当您将鼠标悬停在它们上时,它们将被放大,当您将光标从div上移开时,它将缩小。 But, the aside (the divs parent) is in the correct place where it should be, it's the divs that aren't filling the top of the aside element. 但是,aside(divs父级)在应该放置的正确位置,是div并未填充aside元素的顶部。 How can I get the divs to fill the aside element and not break anything else? 我如何才能使div填充aside元素而不破坏其他任何内容?

 .thing { height: 120px; width: 250px; z-index: 10; position: relative; border: 5px solid brown; } .thing:hover { position: absolute; height: 100%; top: 0; left: 0; z-index: 11; } .report { text-align: left; vertical-align: top; display: table; width: 100%; } .aside { display: table-cell; padding-top: 5px; width: 250px; border-radius: 10px; border: 2px solid black; overflow: hidden; position: relative; height: 385px; } .container { position: relative; width: 750px; height: 400px; border-radius: 5px; border: 1px solid black; overflow: hidden; } 
 <div class="report"> <div id="imgGallary" class="container"> <img src="images/companies.png" alt="" width="750" height="400" /> <img src="gallery" alt="" width="750" height="400" /> </div> <aside class="aside"> <div id="c1"></div> <div class="thing" style="background-color: blue;"> <h1>Find Us!</h1> </div> <div class="thing" style="background-color: orange;"></div> <div class="thing" style="background-color: pink"></div> </aside> </div> 

Your CSS layout is confusing display: table and display: relative . 您的CSS布局令人困惑的display: tabledisplay: relative They aren't compatible like you have them. 它们与您拥有的不兼容。 The preferred way to layout your .container and the aside would be to use f loats . 布置.containeraside的首选方法是使用f loats I revised your example to float those two containers next to each other (roughly at a 80/20 split for the width). 我修改了您的示例,使这两个容器彼此相邻浮动(宽度大致按80/20的比例)。 This has the added bonus of making your layout responsive. 这具有使您的布局具有响应性的额外好处。

Working codepen: http://codepen.io/staypuftman/pen/vKoPmw 工作码本: http ://codepen.io/staypuftman/pen/vKoPmw

.thing {
  height: 120px;
  width: 250px;
  position: relative;
  border: 5px solid brown;
}
.thing:hover {
  position: absolute;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 1;
}
.report {
  text-align: left;
  vertical-align: top;
  display: table;
  width: 100%;
}
.aside {
  padding-top: 5px;
  width: 18%;
  border-radius: 10px;
  border: 1% solid black;
  overflow: hidden;
  float: left;
  position: relative;
  height: 385px;
}
.container {
  float: left;
  width: 80%;
  height: 400px;
  border-radius: 5px;
  border: 1px solid black;
  overflow: hidden;
}

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

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