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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                    <header>
        <h1>2 Column nonequal - 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>
        <aside>

            <h2>[ASIDE] fixed width</h2>
            <h3>Code</h3>
            <h4>HTML</h4>
            <pre>
&lt;header&gt;&lt;/header&gt;
&lt;nav&gt;&lt;/nav&gt;
&lt;main&gt;
  &lt;aside&gt;&lt;/aside&gt;
  &lt;article&gt;
    &lt;div class="article-content"&gt;&lt;/div&gt;
  &lt;/article&gt;
&lt;/main&gt;
&lt;footer&gt;&lt;/footer&gt;
            </pre>
            <h4>CSS</h4>
            <pre>
body {
display: flex;
flex-direction: column;
min-height: 100vh;
        }

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

aside {
flex: 1;
max-width: 20rem;
/* width property of sidebar*/
        }

article {
flex: 1;
display: flex;
        }

div.article-content {
flex: 1;
max-width: 50rem;
/* width property of article content*/
        }
            </pre>
        </aside>
        <article>
            <div class="article-content">
                <h2>[ARTICLE]</h2>
                <h3>Full standard simple 2 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 768px screen full width vertical</li>
                </ul>
                <h4>Aside (sidebar)</h4>
                <ul>
                    <li>fixed width</li>
                    <li>100% height</li>
                    <li>one CSS change to move it right</li>
                </ul>
                <h4>Article</h4>
                <ul>
                    <li>width 100% of left space</li>
                    <li>100% height</li>
                    <li>only one div element to keep max-width of content</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 768px 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>till finding any problems regarded as a final one</LI>
                    <li>Tested in Chrome, Firefox, Opera, Vivaldi, Web (WebKitGTK).</li>
                    <li>Old CSS stuff is commented.</li>
                    <li>Last edition 2018-08-02.</li>
                </ul>
                <p>ARTICLE CONTENT END HERE</p>
          </div>
                    </article>
    </main>
    <footer>
        <h2>[FOOTER] 100% width</h2>
    </footer>
              
            
!

CSS

              
                        /* 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; */
        }

        aside {
            flex: 1;
            max-width: 25rem;
            /* width property of ASIDE */
        }

        article {
            flex: 1;
            display: flex;            
        }

        div.article-content {
            flex: 1;         
            max-width: 50rem;
            /* width property of article content*/
        }

        /* SMALL SCREEN */

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

            main {
                flex-direction: column;
            }

            aside {
                min-width: 100%;
            }
        }

        /* 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;
        }

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

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

        aside {
            background-color: #dc9;
        }

        article {
            background-color: #a96;
        }

        aside ul,
        article ul {
            padding-left: 1rem;
        }

        div.article-content {

            background-color: #f4f4f4;
        }

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

        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;
        }

        h4 {
            margin: auto 0;
            /* if no reset */
        }
              
            
!

JS

              
                
              
            
!
999px

Console