自动调整大小的 css

返回 1

我正在制作一个组件,并试图在不使用 javascript 的情况下实现以下目标(理想情况下使用 flexbox )。将其视为带有页眉和带控件的页脚的信使聊天屏幕。

在此处输入图片说明

规则:

  • 粉红色容器的大小可以是任何大小,它在其父容器上的宽度/高度为 100%,最小为 200px
  • 1 和 3 的高度也是动态的(可能是 100px ,可能是 300 取决于文本)
  • 2 中的内容必须是可滚动的,并且 min-height:200px

我面临的主要问题是我希望 1,2 和 3 不会溢出粉红色容器。有任何想法吗?有点被这个问题难住了,不确定是不是我错过了一些限制,如果没有这些限制,问题就会被描述得很差。

其他

如果这符合您的想法,那么关键是内容 div 的 flex 属性。

我让页眉和页脚使用默认值:1 0 auto 并将内容设置为 200px 作为初始高度(是高度,因为 flex 容器方向设置为列),但它允许 div 增长超过这些 200px .

html, body {
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
}
.container {
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  background: pink;
  display: flex;
  flex-direction: column;
}
.header, .footer {
  background: green;
}
.footer {
  justify-self: flex-end;  
}
.content {
  flex: 1 0 200px;
  overflow: scroll;
}
<div class="container">
  
<div class="header">
For one beautiful night I knew what it was like to be a grandmother. Subjugated, yet honored. I'm a thing. Say what? No, of course not. It was… uh… porno. Yeah, that's it. Hey! I'm a porno-dealing monster, what do I care what you think?  </div>
  <div class="content">
Wow! A superpowers drug you can just rub onto your skin? You'd think it would be something you'd have to freebase. Also Zoidberg. Oh sure! Blame the wizards! It must be wonderful. No! The kind with looting and maybe starting a few fires!

    I suppose I could part with 'one' and still be feared…
    What are their names?
    Wow, you got that off the Internet? In my day, the Internet was only used to download pornography.

Ok, we'll go deliver this crate like professionals, and then we'll go ride the bumper cars. Yes, I saw. You were doing well, until everyone died. Oh, how awful. Did he at least die painlessly? …To shreds, you say. Well, how is his wife holding up? …To shreds, you say.

Fry, we have a crate to deliver. Does anybody else feel jealous and aroused and worried? You'll have all the Slurm you can drink when you're partying with Slurms McKenzie! It's okay, Bender. I like cooking too.

Who said that? SURE you can die! You want to die?! You won't have time for sleeping, soldier, not with all the bed making you'll be doing. Do a flip! As an interesting side note, as a head without a body, I envy the dead.

Who's brave enough to fly into something we all keep calling a death sphere? Goodbye, cruel world. Goodbye, cruel lamp. Goodbye, cruel velvet drapes, lined with what would appear to be some sort of cruel muslin and the cute little pom-pom curtain pull cords. Cruel though they may be…

I didn't ask for a completely reasonable excuse! I asked you to get busy! Stop! Don't shoot fire stick in space canoe! Cause explosive decompression! You won't have time for sleeping, soldier, not with all the bed making you'll be doing.

It's just like the story of the grasshopper and the octopus. All year long, the grasshopper kept burying acorns for winter, while the octopus mooched off his girlfriend and watched TV. But then the winter came, and the grasshopper died, and the octopus ate all his acorns. Also he got a race car. Is any of this getting through to you? A true inspiration for the children.

Yes! In your face, Gandhi! WINDMILLS DO NOT WORK THAT WAY! GOOD NIGHT! I was having the most wonderful dream. Except you were there, and you were there, and you were there! Isn't it true that you have been paid for your testimony?

Whoa a real live robot; or is that some kind of cheesy New Year's costume? When the lights go out, it's nobody's business what goes on between two consenting adults. Fry, you can't just sit here in the dark listening to classical music.

There's one way and only one way to determine if an animal is intelligent. Dissect its brain! And why did 'I' have to take a cab? And remember, don't do anything that affects anything, unless it turns out you were supposed to, in which case, for the love of God, don't not do it!

We'll go deliver this crate like professionals, and then we'll go home. And from now on you're all named Bender Jr. Is that a cooking show? You're going back for the Countess, aren't you? Noooooo!

Look, everyone wants to be like Germany, but do we really have the pure strength of 'will'? Oh, I always feared he might run off like this. Why, why, why didn't I break his legs? Why am I sticky and naked? Did I miss something fun?  </div>
  <div class="footer">
    lorem asdasd
  </div>
</div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

CSS自动调整网格项目的大小

CSS网格自动调整行大小与溢出

自动调整CSS中图像的大小

使图像在CSS网格内自动调整大小

在CSS FlexBox布局中自动调整图像大小并保持宽高比?

如何仅使用CSS来自动调整textareas的大小?

CSS网格-自动高度行,调整为内容大小

CSS / Jquery如何自动调整容器和图像的大小

在CSS中自动调整图像大小以内嵌图像

CSS损坏-自动调整大小不再有效

如何在 CSS 中自动调整跨度圆的大小

使用 CSS 自动调整溢出文本的大小

CSS:将使用Flexbox根据Windows大小自动调整搜索框的大小

如何使用CSS固定宽度和自动调整大小来设置div的样式?

CSS,工具提示:根据工具提示文本自动调整背景大小

React / CSS-当宽度为自动时,内容更改后,动画按钮的宽度将调整大小

自动调整网格大小,允许在 css 中连续第 n 个最大值

如何使自定义CSS按钮根据图像自动调整大小

将CSS过渡或Javascript动画添加到自动调整大小的弹性框布局中

自动调整背景图像大小以适合较小的窗口和移动设备-HTML / CSS

css:是否可以在父元素内移动子元素,以便自动调整父元素的大小

CSS div自动调整大小到内容,带有最大宽度和省略号文本

如何自动调整行的大小以使其适合CSS中的容器?

使用跨度属性时,CSS 网格自动调整大小不起作用

使用CSS调整图像大小

从CSS调整图片大小

CSS 滚动和调整大小

使用CSS调整滑块大小

使用CSS调整图像大小