I would like to accomplish something like what's pictured above, using pure CSS. It must have the following features:
image-container will contain a 3x4 aspect ratio image, which should fill the available viewport height. Consequently, image-container will have a variable width, depending on the height of the viewport.
image-container should be fixed in place as the window scrolls.
content-container should be scrollable.
content-container should fill all the available space between the right edge of image-container and the right edge of the viewport.
In the past, I might have accomplished it with something like this (using jquery):
// style.css
.image-container {
position:fixed;
top: 0px;
left:0px;
bottom: 0px;
}
.image-container img {
height: 100%;
}
// script.js
$(window).load(function() {
var width = $('.image-container').width();
$('.content-container').css({'margin-left': width});
});
Is this possible using only CSS? Perhaps using flex?
css solution
use flex
html,
body {
height: 100%;
overflow: hidden;
}
html {
background-color: #000;
}
.body {
margin: 0;
width: 100%;
height: 100%;
background-color: #333;
color: #999;
}
.container-wrapper {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-start;
height: 100%;
}
.image-container {
background-size: contain;
text-align: center;
height: 100%;
}
.image-container img {
height: 100%;
width: auto;
}
.content-container {
height: 100%;
display: flex;
flex-direction: column;
}
.content-inner-container {
flex-grow: 1;
overflow-y: auto;
padding: 20px 20px 40px 20px;
}
<div class="body">
<div class="container-wrapper">
<div class="image-container">
<img src="http://placehold.it/750x1334">
</div>
<div class="content-container">
<div class="content-inner-container">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p>
</div>
</div>
</div>
</div>
js solution
$(document).ready(function(){
var width = $('.image-container').width();
$('.content-container').css({'width': 'calc(100% - '+width+')'});
});
html,
body {
height: 100%;
overflow: hidden;
}
html {
background-color: #000;
}
.body {
margin: 0;
width: 100%;
height: 100%;
background-color: #333;
color: #999;
}
.container-wrapper {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-start;
height: 100%;
}
.image-container {
background-size: contain;
text-align: center;
height: 100%;
}
.image-container img {
height: 100%;
width: auto;
}
.content-container {
height: 100%;
display: flex;
flex-direction: column;
}
.content-inner-container {
flex-grow: 1;
overflow-y: auto;
padding: 20px 20px 40px 20px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="body">
<div class="container-wrapper">
<div class="image-container">
<img src="https://dummyimage.com/480x640/6b676b/fff">
</div>
<div class="content-container">
<div class="content-inner-container">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p>
</div>
</div>
</div>
</div>
I believe I've accomplished what you're attempting. Check out this fiddle.
.image-container{
height:100vh;
width:100vh - 25%;
border:2px solid red;
display:inline-block;
margin:0;
position:fixed;
}
.content-container{
border:2px solid green;
margin-left: 100vh - 25%;
display:inline-block;
width:100%;
height:2000px;
}
<div class="image-container"></div>
<div class="content-container">
<p>I would like to accomplish something like what's pictured above,
using pure CSS. It must have the following features. </p>
</div>
Related
This has been driving me nuts. Every solution I find doesn't work. Can someone please - once and for all instruct me on how to fix this issue:
Two flex boxes side by side inside a flex display.
Flex box 1 contains long text which needs to be shorted with ellipses. Instead, the long text causes a resize of the flex box 1. I do not want either flex box to resize or reposition based on the contents.
.wrapper {
width: 50%;
display: flex;
background-color: green;
}
.container {
flex: 1;
margin: 10px;
border: 2px solid blue;
height: 200px;
background: pink;
}
span {
user-select: none;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<div class="wrapper">
<div class="container">
<span>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</span>
</div>
<div class="container"></div>
</div>
If you are wanting the 2 boxes to stay equal width, I would just add a width to them (you'll also need to give your span a width to make the ellipsis work):
.wrapper {
width: 50%;
display: flex;
background-color: green;
}
.container {
flex: 1;
margin: 10px;
border: 2px solid blue;
height: 200px;
background: pink;
width: calc(50% - 20px); /* 20px is the left and right margin */
box-sizing: border-box; /* add this so width includes your border */
}
span {
user-select: none;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
display: block; /* add this so you can give the span a width so the ellipsis will work */
width: 100%;
}
<div class="wrapper">
<div class="container">
<span>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</span>
</div>
<div class="container"></div>
</div>
First, get rid of the <span> and put that information into the first <div> with the class = "container" and get rid of the second <div> container class, but keep the first one. In CSS, remove .span, and in .container, add overflow: scroll;
wrapper {
width: 50%;
display: flex;
background-color: green;
}
.container {
flex: 1;
margin: 10px;
border: 2px solid blue;
height: 200px;
overflow: scroll;
background: pink;
}
<div class="wrapper">
<div class="container">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
I'm trying to prevent an image and text from overlapping with each other in html. Currently this is what I have:
But when the screen size gets smaller, the text and image intercept. I'm looking to make it so the text conform to the boarders of the image. This is what's happening now:
Lastly, this is my CSS
.image {
width: 500px;
margin-left: auto;
display: block;
padding-top: 10%;
padding-right: 10%;
}
.text {
font-size: 22px;
padding-top: 10%;
max-width: 700px;
position: absolute;
}
Your issue is with absolute positioning. Whenever you use position:absolute you remove that element from the source flow. You can try to remove the absolute positioning and then try something like the following:
Codepen example
<div class="parent">
<div class="text">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum has been the industry's standard dummy text ever since the 1500s, when an
unknown printer took a galley of type and scrambled it to make a type specimen
book. It has survived not only five centuries, but also the leap into electronic
typesetting, remaining essentially unchanged. It was popularised in the 1960s with
the release of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions of Lorem
Ipsum.
</p>
</div>
<div class="image">
Place your image here.
</div>
And CSS:
.parent {
display: flex;
max-width: 1000px;
margin: 0 auto;
}
.text, .image {
padding: 15px;
}
.image {
width: 500px;
}
.text {
width: calc(100% - 500px);
}
I have the following layout, it is a wrapper (content) which contains some other divs which also have some flex properties.
As you can see from the following link the divs inside content are now scaling up with the size of the content.
.content {
width: 100%;
height: 400px;
display: flex;
overflow: auto;
background-color: blue;
}
.a {
width: 165px;
height: 100%;
flex-grow: 1;
background-color: red;
}
.b {
width: 65px;
display: flex;
padding-top: 20px;
padding-bottom: 20px;
justify-content: center;
background-color: yellow;
height: 100%;
}
.c {
width: 165px;
flex-grow: 1;
margin-right: 15px;
background-color: green;
height: 100%;
}
<div class="content">
<div class="a">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took
a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets
containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="b">
<div class="separator">
s
</div>
</div>
<div class="c">
c
</div>
</div>
What I would like to achieve:
- red, yellow, green divs should me height as the blue (content) div, so when scrolling you do not see the blue part in the bottom
How to achieve this? What is wrong with my code?
I support only latest chrome and I can use CSS3
Your .a is overflowing into .content which is why you see blue section being displayed at the bottom.
By giving .a or rather, all of the children div's an auto overflow, they will follow their parent's height and avoid content overflowing.
Though, it'll introduce a scrollbar. If you are comfortable with hiding the overflowed text, you can use overflow: hidden instead.
.content {
width: 100%;
height: 400px;
display: flex;
overflow: auto;
background-color: blue;
}
.content > div {
overflow: auto;
}
.a {
width: 165px;
height: 100%;
flex-grow: 1;
background-color: red;
}
.b {
width: 65px;
padding-top: 20px;
padding-bottom: 20px;
background-color: yellow;
}
.c {
width: 165px;
margin-right: 15px;
flex-grow: 1;
background-color: green;
height: 100%;
}
<div class="content">
<div class="a">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took
a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets
containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="b">
<div class="separator">
s
</div>
</div>
<div class="c">
c
</div>
</div>
I think the best option for your problem is either
moving overflow: auto; from the .content class to it's children.
changing the height: 400px; to min-height: 400px; if you have no problem with the container being larger than 400px;
adding a wrapper divwith height: 400px; and overflow: auto; around the .content and removing both rules from the .content(imo the best option)
Remove display: flex from .content and height: 100% from .a .b .c and then wrap your elements in a div and give it a display flex.
Working code:
.content {
width: 100%;
height: 400px;
overflow: auto;
background-color: blue;
}
.inner{
display: flex;
}
.a {
width: 165px;
flex-grow: 1;
background-color: red;
}
.b {
width: 65px;
display: flex;
padding-top: 20px;
padding-bottom: 20px;
justify-content: center;
background-color: yellow;
}
.c {
width: 165px;
flex-grow: 1;
margin-right: 15px;
background-color: green;
}
<div class="content">
<div class="inner">
<div class="a">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took
a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets
containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="b">
<div class="separator">
s
</div>
</div>
<div class="c">
c
</div>
</div>
</div>
You could possibly try:
flex: 1 1 auto
It sizes based on width/height properties..
check out
Css Tricks article on it.
EDIT
Remove the flex-grow: 1 and it will be the height you need.
.content {
width: 100%;
height: 400px;
overflow: auto;
background-color: blue;
}
.inner{
display: flex;
}
.a {
width: 165px;
background-color: red;
}
.b {
width: 65px;
display: flex;
padding-top: 20px;
padding-bottom: 20px;
justify-content: center;
background-color: yellow;
}
.c {
width: 165px;
margin-right: 15px;
background-color: green;
}
The problem is here .a section overflow. As you bind the .content 400px height. So there are two ways, You could either free from them to bind height or use overflow scroll for .a section. You can compare the previous and fixed code below.
.content {
width: 100%;
/*height: 400px;*/
display: flex;
overflow: auto;
background-color: blue;
}
.a {
width: 165px;
/*height: 100%;*/
flex-grow: 1;
background-color: red;
}
.b {
width: 65px;
display: flex;
padding-top: 20px;
padding-bottom: 20px;
justify-content: center;
background-color: yellow;
/*height: 100%;*/
box-sizing: border-box;
}
.c {
width: 165px;
flex-grow: 1;
margin-right: 15px;
background-color: green;
/*height: 100%;*/
}
<div class="content">
<div class="a">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took
a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets
containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="b">
<div class="separator">
s
</div>
</div>
<div class="c">
c
</div>
</div>
.content {
width: 100%;
height: 400px;
display: flex;
overflow: auto;
background-color: blue;
}
.a {
width: 165px;
height: 100%;
flex-grow: 1;
background-color: red;
}
.b {
width: 65px;
display: flex;
padding-top: 20px;
padding-bottom: 20px;
justify-content: center;
background-color: yellow;
height: 100%;
}
.c {
width: 165px;
flex-grow: 1;
margin-right: 15px;
background-color: green;
height: 100%;
}
<div class="content">
<div class="a">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took
a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets
containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="b">
<div class="separator">
s
</div>
</div>
<div class="c">
c
</div>
</div>
I want to have the following website style:
The current styles of "OTHER DIV" AND "MOTHER DIV" are displayed in the picture. How do I have to style the other divs like .div_top and .div_bottom so that I get only in .div_bottom a scrollbar if it's needed?
In addition I want that the scrollbar in .div_bottom adjusts itself when .div_top gets bigger (in height):
I think the height of .div_top has to be auto because there is a div inside .div_top which can be hidden and shown with jQuery.
#JonasLoerken
This is your second result. How can I fix this?
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
html,
body {
height: 100%;
padding: 0;
margin: 0;
}
body {
display: flex;
height: 100%;
flex-flow: row nowrap;
overflow: hidden;
}
.Aside {
width: 200px;
background-color: #333;
}
.Main {
flex: 1;
display: flex;
flex-flow: column nowrap;
}
.Main__header {
height: 40px;
min-height: 40px;
background-color: #777;
}
.Main__content {
overflow-y: auto;
}
<aside class="Aside">#Aside</aside>
<main class="Main">
<header class="Main__header">#Header</header>
<section class="Main__content">
<h1 class="Main__content-header">#Scroll</h1>
<p class="Main__content-text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</section>
</main>
Try this:
.wrapper {
height: 100%;
width: 100%;
}
.other-div {
width: 30%;
height: 500px /* User Percent */;
float:left;
background: orange;
display: block;
}
.mother-div {
height: 500px;
width: 70%;
float: right;
background: gray;
}
.top {
height: 30%;
width: 100%;
background: red;
}
.bottom {
height: 70%;
width: 100%;
background: green;
overflow-y: scroll;
overflow-x: hidden;
}
Try it out!
I have to do 3 rows div with scrollable content at the middle row.
Container is absolute position and can't be larger than 100% of the document height.
Container height depends of rows height, and middle row has dynamic height from x to x px.
Can't use max-height: x vh, bacuse of older browser incompatibility.
/* main container can't be larger than 100% of the screen */
.container {
position: absolute;
left: 0;
top: 10px;
width: 250px;
background: green;
max-height: 100%;
}
/* this needs to be scrollable if dynamic content is to large */
.middle-row {
max-height: 90%;
overflow-y: scroll;
background: blue;
}
/* this always needs to be visible */
.last-row {
}
.dummy-large-div {
height: 5000px;
}
<div class="container">
<div class="first-row">some thing</div>
<div class="middle-row">
<div class="dummy-large-div"></div>
</div>
<div class="last-row">
<button>submit</button>
</div>
</div>
Do you have any ideas?
Since you mentioned that you need to support Android 4x - that makes flexbox a viable option (caniuse)
The code also becomes very simple.
Just add the following to the container class
.container {
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
flex-direction: column;
}
and the following to the middle row:
.middle-row {
-webkit-flex: 1;
flex:1;
}
Also, be sure to add -webkit- prefixes to support Android 4.1-4.3
FIDDLE 1 (little content)
FIDDLE 2 (lots of content)
.container {
position: absolute;
display: flex;
flex-direction: column;
left: 0;
top: 0;
width: 250px;
background: green;
max-height: 100%;
}
/* this needs to be scrollable if dynamic content is to large */
.middle-row {
overflow-y: scroll;
background: blue;
flex: 1;
}
<div class="container">
<div class="first-row">some thing</div>
<div class="middle-row">
<div class="dummy-large-div">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer
took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
</div>
<div class="last-row">
<button>submit</button>
</div>
</div>
You need to specify a height to the .container class. It is auto by default and the content is a relative height.