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

              
                <h1>Une page utilisant les grilles et le flexbox ? Facile !</h1>
<header>
  <nav>
    <div class="conteneur-nav">
      <label for="mobile">Afficher / Cacher le menu</label>
      <input type="checkbox" id="mobile" role="button">
      <ul>
        <li class="deroulant"><a href="#">Cours Complets &ensp;</a>
          <ul class="sous">
            <li><a href="#">Cours HTML et CSS</a></li>
            <li><a href="#">Cours JavaScript</a></li>
            <li><a href="#">Cours PHP et MySQL</a></li>
          </ul>
        </li>
        <li class="deroulant"><a href="#">Articles &ensp;</a>
          <ul class="sous">
            <li><a href="#">CSS display</a></li>
            <li><a href="#">CSS position</a></li>
            <li><a href="#">CSS float</a></li>
          </ul>
        </li>
        <li><a href="#">Contact</a></li>
        <li><a href="#">A propos</a></li>
      </ul>
    </div>
  </nav>
</header>

<section class="conteneur">
  <aside class="g1"><p>Aside n°1</p></aside>
  <aside class="g2"><p>Aside n°2</p></aside>
  <article class="g3 sousconteneur">
    <header>
      <h1>Titre de l'article</h1>
      <p>Temps de lecture : 3mn</p>
      <nav>
        <ul>
          <li><a href="#">Chapitre 1</a></li>
          <li><a href="#">Chapitre 2</a></li>
          <li><a href="#">Chapitre 3</a></li>
        </ul>
      </nav>
    </header>
    <article>
      <p>Le sujet de cet exercice est d'apprendre à créer
        une page avec un design complexe et flexibles</p>
    </article>
    <footer>
      <p>A propos de l'auteur : Pierre Giraud...</p>
    </footer>
  </article>
  <aside class="g4"><p>Aside n°3</p></aside>
  <aside class="g5"><p>Aside n°4</p></aside>
</section>

<footer>
  <p>Page HTML / CSS avec grid et flexbox</p>
  <p>© Pierre Giraud / https://www.pierre-giraud.com</p>
</footer>
              
            
!

CSS

              
                *{
  font-family: Avenir, sans-serif;
  font-size: 1em;
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
}
h1{
    font-size: 1.5em;
    margin: 20px auto;
    text-align: center;
    text-transform: uppercase;
}
body > header{
    position: sticky;
    top: 0px;
}
body > header > nav{
    width: 100%;
    height: 42px;
    margin: 0 auto;
}
.conteneur-nav{
    position: absolute;
    width: 100%;
}
body > header > nav input[type=checkbox]{
    display: none;
}
body > header > nav label{
    display: inline-block;
    width: 100%;
    padding: 10px 0px;
    text-align: center;
    background-color: RGBa(220,220,220,0.5);
}
body > header > nav ul{
    display: none;
    list-style-type: none;
    background-color: #555;
}
body > header > nav input[type=checkbox]:checked + ul{
    display: flex;
    flex-flow : column wrap;
}
body > header > nav ul li{
    flex: 1 1 auto;
    text-align: center;
}
body > header > nav > div > ul > li > a{
    color: white;
}
body > header > nav a{
    display: block;
    text-decoration: none;
    color: black;
    padding: 10px 0px;
}
.sous{
    display: flex;
    flex-flow: column wrap;
    z-index: 1000;
}
.sous li{
    flex: 1 1 auto;
    text-align: left;
}
.sous a{
    padding: 10px;
    background-color: RGBa(200,200,200,0.8);
}

.conteneur{
    display: flex;
    flex-flow: column wrap;
}
.g1, .g4{background-color: RGBa(120,205,225,0.4);}
.g2, .g5{background-color: RGBa(225,100,175,0.4);}
.g1, .g2, .g4, .g5{min-height: 100px;}
.sousconteneur{
    display: flex;
    flex-flow: column wrap;
    text-align: center;
    background-color: RGBa(225,215,120,0.4);
}
.sousconteneur h1{
    font-size: 1.2em;
    margin: 10px 0px 0px 0px;
}
.sousconteneur nav ul{
    display: flex;
    flex-flow: row wrap;
    list-style-type: none;
    justify-content: space-around;
}
.sousconteneur nav a{
    display: block;
    color: #333;
}
.sousconteneur article{
    margin: 10px;
}
.sousconteneur footer{
    margin-bottom: 10px;
}

body > footer{
    width: 100%;
    height: 100px;
    background-color: #555;
    color: white;
    text-align:center;
    padding: 20px;
}

@media screen and (min-width: 980px){
    .conteneur-nav{
        position: static;
    }
    body > header > nav label, nav input{
        display: none;
    }
    body > header > nav input[type=checkbox]:checked + ul, body > header > nav ul{
        display: flex;
        flex-flow: row wrap;
        background-color: RGBa(220,220,220,0.5);
    }
    body > header > nav ul li{
        position: relative;
    }
    body > header > nav > div > ul > li > a{
        color: black;
    }
    body > header > nav a{
        border-bottom: 2px solid transparent;
    }
    body > header > nav a:hover{
        color: orange;
        border-bottom: 2px solid gold;
    }
    .sous{
        display: none;
        box-shadow: 0px 1px 2px #CCC;
        background-color: white;
        position: absolute;
        width: 100%;
    }
    body > header > nav > div > ul li:hover .sous{
        display: flex;
        flex-flow: column wrap;
    }
    .sous a{
        border-bottom: none;
        background-color: white;
    }
    .sous a:hover{
        border-bottom: none;
        background-color: RGBa(200,200,200,0.1);
    }
    .deroulant > a::after{
        content:" ▼";
        font-size: 12px;
    }
    .conteneur{
        display: grid;
        grid-template-columns: 1fr 2fr 1fr;
        grid-template-rows: repeat(2,minmax(300px, 1fr));
    }
    .g1{
        grid-column: 1 / 2;
    }
    .g2{
        grid-column: 1 / 2;
        grid-row: 2 / 3;
    }
    .g3{
        grid-column: 2 / 3;
        grid-row: 1 / 3;
    }
    .g4{
        grid-column : 3 / 4;
    }
    .g5{
        grid-column : 3 / 4;
        grid-rows: 2 / 3;
    }
}
              
            
!

JS

              
                
              
            
!
999px

Console