css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
                  <header>
        <h1>Standard 2 Equal Column Layout - Flex</h1>
        <h2>[HEADER] 100% width</h2>
    </header>
    <nav>
        <h2>[NAV] 100% width</h2>
        <ul class="menu">
            <li>
                <a href="#">pos1</a>
            </li>
            <li>
                <a href="#">pos2</a>
            </li>
            <li>
                <a href="#">pos3</a>
            </li>
            <li>
                <a href="#">pos4</a>
            </li>
            <li>
                <a href="#">pos5</a>
            </li>
            <li>
                <a href="#">pos6</a>
            </li>
        </ul>
    </nav>
    <main>
        <div class="one">
            <h2>ONE</h2>
            <h3>Full standard 2 equal column layout [flex model]</h3>
            <h4>Header</h4>
            <ul>
                <li>100% width</li>
                <li>fixed height</li>
            </ul>
            <h4>Nav</h4>
            <ul>
                <li>100% width</li>
                <li>fixed height (if needed)</li>
                <li>standard list elements</li>
                <li>proportional width of elements</li>
                <li>only one change in CSS to set it if the number of elements is changed in float:left version; now in flex
                    is full auto</li>
                <li>in less than 800px screen full width vertical</li>
            </ul>
            <h4>Equal columns</h4>
            <ul>
                <li>the same equal width, irrelevant of number, no need to change CSS</li>
                <li>100% height</li>
                <li>simple CSS change to rearrange the order</li>
            </ul>
            <h4>Footer</h4>
            <ul>
                <li>100% width</li>
                <li>fixed height</li>
                <li>always on bottom</li>
            </ul>
            <h4>Small screens</h4>
            <ul>
                <li>easy to modify media query</li>
                <li>in less than 800px screen layout changed to linear</li>
                <li>in linear version layout long as a content or 100% screen height; only one change CSS to set it</li>
            </ul>
            <h4>Big screens</h4>
            <ul>
                <li>For any top element (oe div.main-content) change default align-items: stretch to align-items: center; and
                    give max-width: (oe 1280 or 1440 px).</li>
            </ul>
            <h4>TODO</h4>
            <ul>
                <li>find any layout problem; all found till now are solved</li>
                <li>more comments in CSS</li>
                <li>separate menu part and a layout part into two Pens</li>
            </ul>
            <hr/>
            <h4>DONE</h4>
            <ul>
                                <li>Tested in Chrome, Firefox, Opera, Vivaldi, Web (WebKitGTK).</li>
                <li>Old CSS stuff is commented.</li>
                <li>Last edition 2018-08-25.</li>
            </ul>
            <p>ARTICLE CONTENT END HERE</p>
        </div>
        <div class="two">
            <h2>TWO</h2>
            <h3>Code</h3>
            <h4>HTML</h4>
            <pre>
&lt;header&gt;&lt;/header&gt;
&lt;nav&gt;&lt;/nav&gt;
&lt;div class="main-content"&gt;
  &lt;div class="one"&gt;&lt;/div&gt;
  &lt;div class="two"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;footer&gt;&lt;/footer&gt;
            </pre>
            <h4>CSS</h4>
            <pre>
body {
display: flex;
flex-direction: column;
min-height: 100vh;
        }

div.main-content {
flex: 1;
display: flex;
/* flex-direction: row-reverse; */
        }

 div.main-content>div {
            flex: 1;
        }
            </pre>
        </div>
    </main>
    <footer>
        <h2>[FOOTER] 100% width</h2>
    </footer>
            
          
!
            
                     /* RESET */

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        /* LAYOUT */

        body {
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }

        main {
            flex: 1;
            display: flex;
            /* flex-direction: row-reverse; */
        }

        main div {
            flex: 1;
        }

        /* SMALL SCREEN */

        @media (max-width:768px) {
            body {
                /* display: block; */
                /* flex gives content height */
                display: flex;
                /* flex gives 100% screen height */
            }

            main {
                flex-direction: column;
            }
        }

        /* MENU */

        ul.menu {
            padding-left: 0;
            /* if no reset */
            display: flex;
            list-style-type: none;
        }

        ul.menu li {
            flex-direction: row;
            flex: 1;
            /* float: left; display: block; */
            /* width: calc(100%/6);*/
        }

        ul.menu li a {
            display: block;
            text-align: center;
        }

        @media (max-width:768px) {
            ul.menu {
                flex-direction: column;
                /* display: block;
                width: 100%;*/
            }
            ul.menu li {
                /* float: none;*/
                /* width: 100%;*/
            }
        }

        /* PRESENTATION */

        body {
            background-color: #000;
        }

        ul {
            padding-left: 2em;
        }

        header {
            background-color: #c0b283;
            min-height: 4em;
        }

        nav {
            background-color: #985;
            min-height: 3em;
        }

        div.one {
            background-color: #ba7;
        }

        div.two {
            background-color: #dc9;
        }

        footer {
            background-color: #dcd0c0;
            min-height: 3em;
        }

        ul.menu li a {
            background-color: #373737;
            color: white;
        }

        ul.menu li a:hover {
            background-color: white;
            color: #373737;
        }

        pre {
            margin: 10px;
            padding: 10px;
            border: 1px solid #ddd;
            background-color: aliceblue;
            font-family: monospace;
        }
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console