我在相对定位的 div
中有一个绝对定位的 div
。我希望内部 div
在 x 轴上溢出,但在 y 轴上不溢出。
<html>
<head>
<style>
#wrapper {
width: 100px;
height: 100px;
background-color: blue;
position: relative;
overflow-y: hidden;
overflow-x: visible;
}
#wrapper div {
width: 50px;
height: 50px;
position: absolute;
right: -25px;
bottom: -25px;
background-color: red;
}
</style>
</head>
<body>
<div id="wrapper">
<div></div>
</div>
</body>
</html>
我在 IE7、IE8、Firefox3、Chrome 的 x 轴内部 div 中使用滚动条进行裁剪或溢出,这不是我想要的。
我觉得我肯定做错了什么。有什么办法可以满足我的要求吗?
最佳答案
I want the inner div to overflow on the y-axis, but not on the x-axis.
你正在使用 CSS 相反,尝试将这个 css 放在你的内部 div 中:
#wrapper div {
............
overflow: auto;
overflow-y: scroll;
overflow-x: hidden;
}
还有你的父 div:
#wrapper {
............
overflow: auto;
}
关于html - 如何在 x 而不是 y 上使相对 div 内的绝对定位 div 溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4116775/