gpt4 book ai didi

html - 使图像相对于其父容器具有静态位置?

转载 作者:行者123 更新时间:2023-11-28 18:22:04 25 4
gpt4 key购买 nike

我正在制作一个图像预览容器,可以在页面底部找到这个 URL:

http://cowperthwaite.dev.mybusinessadmin.com/location/51447

在底部,您可以看到缩略图有一个滚动条,因为父容器的高度无法容纳。这很好,并且正在按预期工作。

我遇到的问题是我需要左侧的大图像始终保持在 View 中,即使向下滚动也是如此。换句话说,我需要它相对于其父 div 保持静态 - 始终在黄色框中 - 而缩略图有一个滚动区域。

我已经尝试了各种position:_______ 变体,但都无济于事,而且我觉得我在这里遗漏了一些更高的概念。我也不确定我想要完成的事情是否有可能实现。

有人介意提供一些见解吗?提前致谢

编辑:derp,没有提供我的代码...

HTML:

<div class="pictureBoxContainer">
<div class="pictureBox">
<div class="pBoxLeftColumn">
<?php
echo "<div class='pBoxLargeImageContainer'>";
echo "<img src='$pictureLinks[0]' id='largeImage' alt='Primary Image' class='pBoxLargeImage'>";
echo "</div>";
?>
</div>
<div class="pBoxRightColumn">
<?php
foreach ($pictureLinks as $picture)
{
echo "<div class='pBoxSmallImageContainer'>";
echo "<img src='$picture' alt='Thumbnail' class='pBoxSmallImage'>";
echo "</div>";
}
?>
</div>
</div>
</div>

CSS:

.pictureBoxContainer {
padding: 12px;
clear:left;
clear:right;
width: 100%;
background-color: #F7D961;
border-radius: 12px;
max-height: 350px;
}

.pictureBox {
background-color: #FFF;
border-radius: 12px;
width: 97%;
overflow: auto;
padding: 12px;
max-height: 300px;
}

.pBoxLeftColumn {
display: block;
float: left;
min-width: 49.99%;
max-width: 49.99%;
overflow: auto;
}

.pBoxRightColumn {
display: block;
float: right;
min-width: 49.99%;
max-width: 49.99%;
overflow: auto;
}

.pBoxSmallImageContainer {
height: 103px;
width: 145px;
float: left;
padding: 3px;
margin: 3px;
background-color: #F7D961;
border-radius: 2px;
position: relative;
}

.pBoxSmallImage {
max-height: 95px;
max-width: 138px;
margin: auto;
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}

.pBoxLargeImageContainer {
width: 100%;

}

.pBoxLargeImage {
border-radius: 6px;
min-width: 450px;
max-height: 300px;
position: static;
}

最佳答案

position: relative 添加到 pictureBoxContainer div 并将以下样式添加到 pBoxLeftColumn div:

.pBoxLeftColumn {
display: block;
left: 25px;
max-width: 49.99%;
min-width: 49.99%;
position: absolute;
top: 25px;
}

关于html - 使图像相对于其父容器具有静态位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16612935/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com