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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://kit.fontawesome.com/0138c8d5d4.js"></script>
    <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css">    
    <title>Flexbox Mega Menu</title>
</head>

<body>
    <div class="wrapper">
        <div class="header-container">
            <div class="main-menu-container">
                <ul class="main-menu">
                    <li><a href="#">Home</a></li>
                    <li><a href="#">Advert</a></li>
                    <li><a href="#">Contact</a></li>
                    <li><a href="#">Subscribe</a></li>
                    <li><a href="#">Shop</a></li>
                    <li><a href="#">Ads</a></li>
                </ul>

                <ul class="resources">
                    <li><a href="#"><i class="fas fa-play-circle">&nbsp;</i> Multimedia</a></li>
                    <li><a href="#"><i class="fas fa-print">&nbsp;</i> Print</a></li>
                    <li><a href="#"><i class="fas fa-tablet-alt">&nbsp;</i> Apps</a></li>
                </ul>

                <ul class="login-block">
                    <li><a href="#">Register</a></li>
                    <li><a href="#">Login</a></li>
                </ul>
            </div>
            <div class="highlights">
                <div class="logo">
                    <img src="https://place-hold.it/120/fff/000.png?text=Place logo 120" alt="Newspaper Logo">
                </div>
                <ul class="topics">
                    <li><a href="#">Day Topics</a></li>
                    <li><a href="#">Crisis in Middle East</a></li>
                    <li><a href="#">Election Polls</a></li>
                    <li><a href="#">Springfield Isotopes</a></li>
                    <li><a href="#">Concert in Town</a></li>
                </ul>
                <div class="social-wrapper">
                    <ul class="social">
                        <li><a href="#"><i class="fab fa-facebook"></i></a></li>
                        <li><a href="#"><i class="fab fa-twitter"></i></a></li>
                        <li><a href="#"><i class="fab fa-instagram"></i></a></li>
                    </ul>
                    <div class="search">
                        <input type="search" class="search-box" name="q">
                        <span><i class="fas fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div id="news-menu" class="news-menu">
                <ul class="news-categories">
                    <li class="local">
                        <a href="#">Local</a>
                        <ul class="megamenu-local">
                            <li>
                                <ul class="main-topics-list">
                                    <li><a href="#">Security</a></li>
                                    <li><a href="#">Movility</a></li>
                                    <li><a href="#">Our City</a></li>
                                    <li><a href="#">Downtown</a></li>
                                    <li><a href="#">Ecology</a></li>
                                </ul>
                            </li>
                            <li>
                                <a href="#">
                                    <img src="http://lorempixel.com/640/300/nature/1" alt="city image">
                                </a>
                            </li>
                            <li>
                                <ul class="main-news">
                                    <li><a href="#">Main News #1</a></li>
                                    <li><a href="#">Main News With a Really Really Extraordinary Long Title</a></li>
                                    <li><a href="#">Main News #3</a></li>
                                </ul>
                            </li>
                        </ul>
                    </li>
                    <li class="national"><a href="#">National</a></li>
                    <li class="international"><a href="#">International</a></li>
                    <li class="business"><a href="#">Business</a></li>
                    <li class="sports"><a href="#">Sports</a></li>
                    <li class="opinion"><a href="#">Opinion</a></li>
                    <li class="culture"><a href="#">Culture</a></li>
                    <li class="tendencies"><a href="#">Tendencies</a></li>
                    <li class="technology"><a href="#">Technology</a></li>
                    <li class="entertainment"><a href="#">Entertainment</a></li>
                </ul>
            </div>
        </div>
    </div>
</body>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script type="text/javascript" src="script.js"></script>
</html>
              
            
!

CSS

              
                /* BASIC RESET STYLES */

html {
    box-sizing: border-box;
    font-size: 16px; 
}

*, *:before, *:after {
  box-sizing: inherit;
}

body, h1, h2, h3, h4, h5, h6, p, ol, ul {
  margin: 0;
  padding: 0;
  font-weight: normal;
}

body {
    margin-top: 30px;
}

ol, ul {
   list-style: none;
}

.hidden-megamenu-local {
  display: none;
}

/* FLEXBOX */

/* Main menu Container */

.main-menu-container,
.main-menu,
.resources,
.login-block {
  display: flex;
}

.main-menu {
  flex-grow: 3;
}

.resources {
  flex-grow: 2;
}

.login-block {
  flex-grow: 1;
}

/* Highlights section */

.highlights,
.topics,
.main-topics-list,
.social,
.search,
.social-wrapper {
  display: flex;
}

.logo {
  flex-basis: 25%;
}

.topics {
  flex-basis: 60%;
}

.topics li {
  flex-basis: 22.5%;
}

.topics li:first-of-type {
  flex-basis: 10%;
}

.social-wrapper {
  flex-basis: 15%;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

/* News menu and Mega menu */

.news-menu,
.news-categories,
.megamenu-local, 
.main-news {
  display: flex;
}

.news-menu {
  justify-content: center;
}

.megamenu-local {
  align-items: center;
}

.megamenu-local > li:nth-of-type(odd) {
  flex-basis: 25%;
}

.megamenu-local > li:nth-of-type(even) {
  flex-basis: 50%;
}

.main-topics-list,
.main-news {
  flex-direction: column;
  align-items: center;
}

/* OTHER STYLES */

/* Main menu container */

.main-menu-container {
  background-color: black;
}

.header-container {
  background-image: url(http://lorempixel.com/640/300/abstract/6);
  background-repeat: repeat-x;
}

/* Links and images  */

a {
  display: block;
  text-decoration: none;
  text-transform: uppercase;
  padding: 0.5em 0.5em;
  color: whitesmoke;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: normal;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Login block links */

.login-block li a {
  border: 1px solid whitesmoke;
  border-radius: 3px;
  background-color: #868282;
  padding: 0 0.8em;
  margin-top: 0.5em; 
 }
 
 .login-block li a:hover {
   background-color: rgb(250, 224, 77);
   color: black;
 }
 
 .login-block li:first-of-type {
   margin-right: 0.5em; 
 }

 /* Logo Image */

 .logo img {
  margin: 0 auto;
}

/* First topic */

.topics li:first-of-type a {
  font-weight: 700;
  letter-spacing: 3px;
}

/* Other borders and margins */

.social i {
  font-size: 1.8em;
}

.search {
  padding: 1em;
}

.search-box {
  background-color: transparent;
  line-height: 1.5em;
  color: whitesmoke;
}

.fa-search {
  color: whitesmoke;
  position: relative;
  right: 2em;
  top: 0.3em;
}

.highlights {
  margin-top: 2em;
}

.topics li {
  border: 1px solid whitesmoke;
  border-top: none;
}

.topics li:first-of-type {
  border-left: none;
}

.social li {
  border-right: 1px solid whitesmoke;
  padding: 0 1em;
}

.social li:last-of-type {
  border-right: none;
}

.news-categories {
  padding-top: 1.5em;
}

.news-categories > li > a {
  font-size: 1.1em;
  font-weight: 700;
}

li.local {
  border-top: 5px solid #9c1f42;
}

li.national {
  border-top: 5px solid #e13249;
}

li.international {
  border-top: 5px solid #db5c72;
}

li.business {
  border-top: 5px solid #96B45C;
}

li.sports {
  border-top: 5px solid #006638;
}

li.opinion {
  border-top: 5px solid #FF9E37;
}

li.culture {
  border-top: 5px solid #6C2869;
}

li.tendencies {
  border-top: 5px solid #332265;
}

li.technology {
  border-top: 5px solid #195EB5;
}

li.entertainment {
  border-top: 5px solid #58C5E0;
}

li.local > a:hover {
  background-color: #9c1f42;
}

li.national > a:hover {
  background-color: #e13249;
}

li.international > a:hover {
  background-color: #db5c72;
}

li.business > a:hover {
  background-color: #96B45C;
}

li.sports > a:hover {
  background-color: #006638;
}

li.opinion > a:hover {
  background-color: #FF9E37;
}

li.culture > a:hover {
  background-color: #6C2869;
}

li.tendencies > a:hover {
  background-color: #332265;
}

li.technology > a:hover {
  background-color: #195EB5;
}

li.entertainment > a:hover {
  background-color: #58C5E0;
}

/* Positioning the mega menu */

.wrapper {
  position: relative;
  width: 80%;
  margin: 0 auto;
}

.megamenu-local {
  position: absolute;
  background-color: rgb(228, 228, 228);
  margin: 0 auto;
  left: 0;
  padding-bottom: 1em;
}

.megamenu-local a {
  color: #838383;
}

.main-news {
  width: 95%;
}

.main-news li {
  border-bottom: 2px inset #838383;
  line-height: 1.8em;
  text-align: center;
}

.main-news li:last-of-type {
  border-bottom: none;
}
              
            
!

JS

              
                /* Replace the class megamenu-local with hidden-megamenu-local in the HTML in order to test the JS */

$('li.local').hover(
   function(){ $('.hidden-megamenu-local').addClass('megamenu-local') },
   function(){ $('.hidden-megamenu-local').removeClass('megamenu-local') }
)

$('.megamenu-local').hover(
   function(){ $('.hidden-megamenu-local').addClass('megamenu-local') },
   function(){ $('.hidden-megamenu-local').removeClass('megamenu-local') }
)
              
            
!
999px

Console