jquery - "overflow-x:hidden"只有一侧?

标签 jquery html css

是否可以仅在一侧隐藏元素的水平溢出:左侧或右侧?类似于 overflow-x-right:hidden;。我愿意接受基于 css 和 jquery 的技巧。

最佳答案

这是使用 clip-path 实现的方法,它取代了已弃用的 clip 属性:

.outer {
  background-color: rgba(0,0,255,.5);
  width: 100px;
  height: 100px;
  margin: 100px;
  clip-path: inset( -100vw -100vw -100vw 0 );
}

.inner {
  background-color: rgba(255,0,0,.5);
  width: 200px;
  height: 80px;
  position: relative;
  top: 10px;
  left: -50px;
}
<div class="outer">
  <div class="inner"></div>
</div>

请注意,截至 2017 年 12 月,browser support isn't very good .

进一步阅读:

关于jquery - "overflow-x:hidden"只有一侧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8953971/

相关文章:

html - 图像未针对 ipad 屏幕/iphone 模式调整大小

javascript - d3 - 在 svg 元素之上渲染 html 表格

javascript - 如何正确缩放图像以适应 maxdim-by-maxdim 方形区域?

jquery - 如何使用 jQuery 更改 CSS 属性?

javascript - 奇数表行行为

jQuery .css() 回退?

jquery - 使用 Web Audio API,是否可以关闭扬声器的音量,但输入仍然存在

javascript - position() 被视为函数

javascript - css3 的 Canvas 比例问题

css - 使用 css3 翻转图标