在调整窗口大小时,绝对定位的 DIV 移动到HTML 的右边界之外- 因此出现水平滚动条。但我只需要在中央固定宽度列上滚动条。有什么解决办法吗?如何在 HTML-tag 右边框下悄悄获得正确的评论?
<!DOCTYPE HTML>
<html>
<head><title>Absolute position right scrollbar removing</title></head>
<body>
<style>
body {line-height: 1.5em;}
p {margin: 0;}
.page {position: relative; width: 400px; margin: 0 auto; background-color: #ccc;}
.comment-container {position: relative; width: 100%; height: 0; top: -1px;}
.comment {position: absolute; width: 200px; background-color: #eee; top: -1.5em; border-top: 1px solid #aaa;}
</style>
<div class="page">
<p>
Text and images here. Scrollbar should appear when window size is less than 400px.
</p>
<div class="comment-container">
<div class="comment" style="right: -200px;">
Some outside comment on the right. Horizontal scrolbar on html-tag appears on window squeezing.
Is there any way to remove the scrollbar when this element goes outside?
</div>
</div>
<p>
More text, text and text goes here.
</p>
<div class="comment-container">
<div class="comment" style="left: -200px;">
Some outside comment on the left. No scrollbar on window resizing.
</div>
</div>
</div>
</body>
</html>