我有如下HTML:
<div class="container">
<div class="scrollable-block">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
<div class="absolute-div"></div>
</div>
同时还有CSS:
.container {
width: 200px;
height: 300px;
background: green;
}
.scrollable-block {
width: 200px;
max-height: 250px;
overflow: scroll;
position: relative;
}
.absolute-div {
width: 20px;
height: 20px;
background: purple;
position: absolute;
top: 0;
right: -10px;
}
在这里有一个实时演示:http://jsfiddle.net/BYTam/1/ 绿色的 div 是容器,具有固定的宽度。黄色的 div 在其中并具有最大高度和 overflow-y: scroll 属性。它应该与绿色的 div 具有相同的宽度。我正在尝试绝对定位紫色的 div,相对于黄色的 div,但在绿色的 div 外部 - 原因是我不希望黄色的 div 有水平滚动条。这是否可能?
谢谢!