html - 我想要我的容器 block 的折叠行为

标签 html css containers

我花了几个小时寻找这个问题的解决方案。我发现的只是所需行为的反面。 正如标题所说,我想要的是我的''容器在具有属性'position:fixed'时崩溃并且没有高度 这是代码块。

<div style="position:fixed;right:0;bottom:0">
    <div style="float:left">First DIV</div>
    <div style="float:left">Second DIV</div>
</div>

谢谢

最佳答案

基于评论

i want the behavior of multiple chat block grouped in the container (like on common chat clients on facebook or other sites). The container is the block fixed on bottom right the window containings one or several chat blocks.

因此,实际上高度不会为零,但您似乎希望 div 的高度不大于其内容的总和。

如果您没有在 div 上指定高度,那么这将是固定位置 div 的默认值。

这样的东西就足够了。

.mydiv {
  background: lightblue;
  position: fixed;
  right: 0;
  bottom: 0;
}
.mydiv div {
  border-bottom: 1px solid red;
  max-width: 200px;
  background: lightgreen;
}
.mydiv div:nth-child(even) {
  background: lightgrey;
}
<div class="mydiv">
  <div>First DIV</div>
  <div>Second DIV</div>
  <div>Third loooooong DIV</div>
  <div>Fourth DIV</div>
  <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nam facere dolorum amet eum eos alias.</div>
</div>

关于html - 我想要我的容器 block 的折叠行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29143367/

相关文章:

html - 如何在 opencart 2.0.1.1 中的奖励积分通知电子邮件中应用 css 样式?

html - 如何从原始 HTML 代码制作 CSS 菜单

html - 有没有办法在不弹出信息栏的情况下使元素透明?

javascript - 如何保存更新应用于您的页面 html

c++ - 应该弃用 std::list 吗?

c++ - 使用 map<int, Foo> 而不是 vector<Foo> 来避免指针失效

docker - 是否可以填充在Bluemix Containers中创建的Volume的内容?

javascript - 如何改变模态内容(无需 Bootstrap )

html - td元素的Bootstrap边框与colspan的问题

jquery - 更改将在手机上显示的主要内容的 jQuery Mobile 背景颜色