Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!doctype html>
<!-- forked from https://codepen.io/carl-vega/pen/KbGyYX -->
<html lang="en">
    <head>
    <title>Vertical demo</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel = "stylesheet" type = "text/css" href = "./styles.css" />
    </head>

    <style>
    </style>

    <body>

        <div class="container">
            <div class="box box-1">box 1</div>
            <div class="box box-2">box 2
							Example for SO: <a href="https://stackoverflow.com/questions/25098042/fill-remaining-vertical-space-with-css-using-displayflex">Fill remaining vertical space with CSS using display:flex</a>
<hr/>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eleifend fermentum varius. Nunc laoreet suscipit nisl, aliquet pellentesque mauris pharetra vel. Proin feugiat blandit nulla nec rutrum. Fusce ac est dignissim, eleifend metus eget, pulvinar erat. Praesent tempus dui consequat vehicula sagittis. Aenean eros lectus, venenatis tristique commodo non, finibus sed mi. Nam non lobortis nisl. Proin sapien nibh, lobortis ac tempus vel, scelerisque eu orci. Suspendisse cursus, libero eu tincidunt consectetur, diam velit consequat nisl, quis sollicitudin ante lacus non odio. Pellentesque erat sapien, volutpat ac diam vel, semper fermentum ipsum. In consequat urna id sollicitudin euismod. Curabitur nec viverra leo.

Phasellus eget consectetur augue. Sed tempor, turpis sodales convallis molestie, tellus tortor porttitor ligula, vitae vehicula mauris dui et diam. Curabitur egestas imperdiet efficitur. Aenean massa justo, commodo nec tellus nec, suscipit venenatis velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam auctor dui nec faucibus fermentum. Nullam faucibus felis sit amet nisi lobortis, in auctor turpis malesuada. Quisque sed pharetra diam. Phasellus a euismod nulla, nec pellentesque risus. Pellentesque at consequat dui. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent diam lacus, varius a tempor at, imperdiet vel tortor. Fusce mollis aliquam velit ut mollis. Nunc quis justo at odio auctor convallis.

Curabitur interdum lacinia suscipit. Proin vulputate magna sed dolor semper, id suscipit nisi scelerisque. Suspendisse eu turpis vel ex rutrum ullamcorper. Nulla sed lacus consequat, malesuada nulla vitae, tristique erat. Vestibulum ornare odio ut tempus rhoncus. Nullam at elementum neque, quis dictum turpis. Proin auctor vulputate tortor. Etiam dictum elementum pretium. Ut ornare felis eget nisl facilisis, ac lacinia arcu convallis. Praesent laoreet ullamcorper lobortis. Curabitur volutpat dolor nisi, non mollis velit vulputate sit amet. Mauris faucibus enim in varius mattis.

Duis arcu ipsum, congue vitae orci ut, sollicitudin hendrerit metus. Suspendisse imperdiet dolor metus, ut hendrerit arcu rhoncus sit amet. Aenean vitae facilisis lacus. Mauris ut volutpat eros. Quisque ullamcorper vel mauris at egestas. Nullam risus ex, pretium vel lectus ullamcorper, venenatis iaculis ante. Sed eget semper arcu. Fusce porttitor egestas enim eget sodales. Mauris leo orci, tempor sed nisl at, tristique convallis dolor. Suspendisse sed nibh id mauris aliquet accumsan. Nulla porttitor fringilla gravida. Interdum et malesuada fames ac ante ipsum primis in faucibus. Mauris at diam mauris.

Duis non gravida mi, et efficitur purus. Maecenas commodo ultrices nisl, quis finibus nunc bibendum quis. In ornare fermentum justo, id suscipit dui varius vel. Proin at pharetra nisi. Morbi diam lectus, bibendum id tempor non, euismod non leo. Praesent in placerat mi. Duis nunc leo, viverra placerat ante ac, lobortis dignissim diam. Nullam euismod justo et fermentum pharetra. Integer aliquet vehicula tortor vel sodales.

					</div>
            <div class="box box-3">box 3</div>
        </div>
    </body>
</html>

              
            
!

CSS

              
                *{
    /*
    https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing

    It is often useful to set box-sizing to border-box to layout elements. This makes dealing with the sizes of elements much easier, and generally eliminates a number of pitfalls you can stumble on while laying out your content.  
    
    On the other hand, when using position: relative or position: absolute, use of box-sizing: content-box allows the positioning values to be relative to the content, and independent of changes to border and padding sizes, which is sometimes desirable.*/
    box-sizing: border-box;
    margin: 0px;
	  padding: 0px;
}

/* ALL CONTAINER up to the flex container, including the flex container itself */
html,
body,
.container {
	/* necessary */
	height: 100%;
	min-height: 100%;
}

.container {
	/* for the flex container */
	display: flex;
	flex-direction: column;
}

.container .box {
	text-align: center;
	font-family: sans-serif;
	font-size: 30px;
	// padding: 20px;

	/* not necessary
    this is actually for the each box content to be aligned inside of it */
	// display: flex;
	// flex-direction: column;
	// justify-content: center;
}

.container .box-1 {
	background-color: red;
	// height is used for this cell as preferred
	// https://www.w3.org/TR/css-sizing-3/#preferred-size-properties
	// but not obeyed! when size of the page becomes too small to accomodate it
	// in that case it does contributes but not obeyed, as for example min-height
	// https://www.w3.org/TR/css-sizing-3/#min-size-properties
	// height: 400px;
	// if you uncoment flex, it will take precedence 
	// preferred over its (in this case) euqivalente https://www.w3.org/TR/css-flexbox-1/#propdef-flex-grow
	// flex: 1;
}

.container .box-2 {
	background-color: blue;
	// height is not taken into consideration as a preffered size 
	// when flex directive is provided
	// https://www.w3.org/TR/css-flexbox-1/#propdef-flex says:
	/**  When a box is a flex item, flex is consulted **instead of the [main size property](https://www.w3.org/TR/css-flexbox-1/#main-size-property)** to determine the main size of the box */
	// height: 400px;
	flex: 1;
	overflow-y: auto;
}

.container .box-3 {
	background-color: white;
	// flex: 2;
	// it is overwritten by flex directive and not respected any more
	/* **WARNING**: if this value is set to smaller than necessary for the inner content to fit, we will endup with the overflow and vertical page scroller, which can surely avoided with `overflow-y: scroll;`*/
	height: 60px;
	// height: 30px;
	// overflow-y: scroll;
	// however, `min-height` is still taken in the consideration in the same manner, so if flex directive can be accomodated without breaking min-height, it will be, but if it cannot the min-height will be respected, even for the price of introducing the scroller on the whole page
	// min-height: 220px;
	// similar to `max-height`; it is still taken in the consideration
	// max-height: 100px;
}

              
            
!

JS

              
                
              
            
!
999px

Console