中心收藏我工作的一个收藏夹。我需要根据其内容动态调整大小。但我也需要它在屏幕中居中。我想是这样的:动态高度
HTML:
<div class="lightbox-background">
<div class="lightbox">
LIGHTBOX CONTENT
</div>
</div>
CSS:
.lightbox-background {
background-color: rgba(0,0,0,0.9);
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
z-index: 50;
}
.lightbox {
background-color: white;
width: 780px;
z-index: 100;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
height: auto !important;
max-height: 90%;
}
我不能使它工作。如果可能的话,我想避免使用JS。我该怎么做?
过了一段时间,直到我明白为什么它的工作原理。谢谢您的帮助。 您还可以设置 “FONT-SIZE:0;”到容器和“字体大小:14px的”,以除去内联块元件之间的空白空间,以它的孩子。如果您的容器太小,额外的空白可能会导致未经处理的结果。 –