我目前正在尝试调整我一直在研究的图像滑块。我要做的是在用户调整浏览器大小时保持滑块与浏览器左侧相遇的相同位置。检查下面的示例
+------------------------+
| body |
+--------------------------------------------------+
| | |
| |<- Keep this aligned at the same |
| | position on browser resize? |
| | |
| | |
| | |
+--------------------------------------------------+
| |
+------------------------+
HTML:
<div id="scrollerWrapper">
<div id="imageScroller">
<img class="i" href="..." />
<img class="i" href="..." />
<img class="i" href="..." />
<img class="i" href="..." />
</div>
</div>
browserHeight = parseInt($(window).height(), 10);
galleryMargin = browserHeight * 0.025;
imageHeight = browserHeight - 80 - (galleryMargin * 2);
if (imageHeight < 250) {
imageHeight = 250;
}
$(".i").css("height", imageHeight + "px");