css - 可调整大小的容器,其中包含的元素会溢出。合并溢出 :visible with resizability

标签 css resizable

我需要创建一个带有上拉切换按钮的容器 div(但这也可以是一个简单的跨度、标签或其他任何东西),但这也可以重新-相当大

不幸的是( https://css-tricks.com/almanac/properties/r/resize/ ):

Super important to know: resize does nothing unless the overflow property is set to something other than visible, which is its initial value for most elements.


我试着写一个 simple example比较每个冲突属性的限制(仅在摘录下方):

<div class="container">
  <button>Toggle</button>
  <div class="content">...</div>
</div>

<div class="container overflow-hidden">
  <button>Toggle</button>
  <div class="content">...</div>
</div>

.container {
  border:solid 1px red;
  position:relative;
  resize:horizontal;
}

.overflow-hidden {
  overflow:hidden;
}

button {
  position:absolute;
  top:-20px;
}

我不知道如何解决这个问题,所以如何有一个可以显示溢出元素的可调整大小的容器(可能只用 CSS)?

最佳答案

how to have a resizable container that can show an overflowed item

要使 resize 起作用,元素需要溢出而不是可见,所以答案是


I need to create a container div with a pulled-up toggle button

如果你稍微改变你的标记,你可以这样做

Fiddle demo

堆栈片段

.container {
  position: relative;
  display: inline-block;
}

.overflow-hidden {
  border: solid 1px red;
  width: 50%;
  height: 80%;
  margin-top: 18px;
  resize: horizontal;
  padding: 20px;
  overflow: hidden;
}

button {
  position: absolute;
  top: 0;
  left: 0;
}

.content {
  border: solid 1px blue;
  height: 100px;
}
<div class="container">
  <button>Toggle</button>
  <div class="overflow-hidden">
    <div class="content">
      WITH "overflow:hidden":
      <br> "resize" feature is available <strike>but pulled-up button is obviously semi-hidden</strike>
    </div>
  </div>
</div>

关于css - 可调整大小的容器,其中包含的元素会溢出。合并溢出 :visible with resizability,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43320929/

相关文章:

javascript - 网页颜色检索适用于 jQuery 但不适用于 javascript

jquery - 将一些 jQuery 添加到文本区域以调整它的高度

asp.net - <div> 元素在 <ul> 元素内,层次结构在 IE、ASP.NET Repeater 控件中发生变化

javascript - jQuery resizing() "Containment"参数不接受数组

java - 如何使图像大小可调

html - 使用 html 创建类似 GUI 的界面

css - 在 react 中内联自定义 CSS

javascript - 解决图像上 jQuery 可拖动和可调整大小的问题

java - 调整数组大小 数组

swift - 动态 UIWebView 高度和 UITableViewCell 调整大小