<nav>
<ul class="desktop-menu" id="desktopMenu">
<li>
<a id="home" href="#">
<img src="https://eliya33.github.io/church/images/yonsei-logo-100x100.png" class="yonsei-logo" alt="Yonsei University Logo">LOGO NAME</a>
</li>
<li class="desktop-link">
<a href="#">Link One</a>
<a class="caret" href="#" onclick="caretDropdownOne(); return false;">∨</a>
<ul class="dropdown-menu" id="caretDropdownOne">
<li><a href="#">Sublink One</a></li>
<li><a href="#">Sublink Two</a></li>
<li><a href="#">Sublink Three</a></li>
<li><a href="#">Sublink Four</a></li>
<li><a href="#">Sublink Five</a></li>
</ul>
</li>
<li class="desktop-link">
<a href="#">Link Two</a>
<a class="caret" href="#" onclick="caretDropdownTwo(); return false;">∨</a>
<ul class="dropdown-menu" id="caretDropdownTwo">
<li><a href="#">Sublink One</a></li>
<li><a href="#">Sublink Two</a></li>
<li><a href="#">Sublink Three</a></li>
<li><a href="#">Sublink Four</a></li>
<li><a href="#">Sublink Five</a></li>
</ul>
</li>
<li class="desktop-link">
<a href="#">Link Three</a>
<a class="caret" href="#" onclick="caretDropdownThree(); return false;">∨</a>
<ul class="dropdown-menu" id="caretDropdownThree">
<li><a href="#">Sublink One</a></li>
<li><a href="#">Sublink Two</a></li>
<li><a href="#">Sublink Three</a></li>
<li><a href="#">Sublink Four</a></li>
<li><a href="#">Sublink Five</a></li>
</ul>
</li>
<li class="desktop-link">
<a href="#">Link Four</a>
<a class="caret" href="#" onclick="caretDropdownFour(); return false;">∨</a>
<ul class="dropdown-menu" id="caretDropdownFour">
<li><a href="#">Sublink One</a></li>
<li><a href="#">Sublink Two</a></li>
<li><a href="#">Sublink Three</a></li>
<li><a href="#">Sublink Four</a></li>
<li><a href="#">Sublink Five</a></li>
</ul>
</li>
<li class="desktop-link">
<a href="regulations.html">Link Five</a>
<a class="caret" href="#" onclick="caretDropdownFive(); return false;">∨</a>
<ul class="dropdown-menu" id="caretDropdownFive">
<li><a href="#">Sublink One</a></li>
<li><a href="#">Sublink Two</a></li>
<li><a href="#">Sublink Three</a></li>
<li><a href="#">Sublink Four</a></li>
<li><a href="#">Sublink Five</a></li>
</ul>
</li>
<li id="last-desktop-link" class="desktop-link">
<a href="muut.html">Link Six</a>
</li>
<li id="mobile-menu">
<a id="home2" href="index.html">
<img src="https://eliya33.github.io/church/images/yonsei-logo-100x100.png" class="yonsei-logo" alt="Yonsei Univeristy Logo">
<span id="logo-text">LOGO NAME</span>
</a>
<a id="mobile-icon-container" href="#" onclick="responsiveMenu(); return false;">
<img id="mobile-icon" src="https://eliya33.github.io/church/images/mobile-menu-icon-125x125.png" alt="Mobile Menu Icon">
</a>
</li>
</ul>
</nav>
body {
margin: 0;
}
/* 1. General Links */
img {
width: 100%;
display: block; /* To remove background color under images */
}
li {
list-style-type: none;
}
a,
a:link,
a:visited {
color: #fff;
display: block;
font-size: 1.25em;
font-weight: 500;
padding: 1em;
text-decoration: none;
}
a:hover,
a:focus,
a:active {
background: #3277ae;
}
/* Removes border around images in menu for IE10 */
a img {
border: 0;
}
/* 2. Desktop Nav Menu */
.desktop-menu {
background: #002147;
margin: 0;
padding: .75em 0;
position: absolute; /* Prevents parent ul from collapsing because of floated children li's. Alternative to overflow: auto/none; */
top: 0;
width: 100%;
z-index: 1; /* Allows desktop menu to show over slider */
}
.desktop-link {
float: left;
margin-top: 1.75em;
text-align: center;
}
/* 2.1 Desktop Home Link */
#home {
border: 1px solid #fff;
float: left;
font-size: 1em;
margin: .5em 1em .5em 1em;
padding: .75em;
}
#home,
#home:link,
#home:visited,
#home:hover,
#home:focus,
#home:active {
color: #fff;
background: none;
}
.yonsei-logo {
margin: -.5em auto .5em auto;
width: 4em;
}
/* 2.2 Desktop Dropdown-menu */
a.caret,
#mobile-menu,
.dropdown-menu {
display: none; /* Removes mobile menu, caret links, and dropdown menu (when menu items are not hovered) on large screens */
}
.desktop-link:hover .dropdown-menu {
display: block; /* Shows dropdown menu when menu items are hovered */
}
.dropdown-menu {
background: #fff;
box-shadow: 2px 2px 10px #777;
font-size: .7em;
padding: 0;
position: absolute;
text-align: left;
width: 20em;
}
.dropdown-menu a,
.dropdown-menu a:link,
.dropdown-menu a:visited {
border-top: 1px solid #002147;
color: #002147;
font-size: 1.5em;
font-weight: 600;
}
.dropdown-menu a:hover,
.dropdown-menu a:focus,
.dropdown-menu a:active {
color: #fff;
}
/* 3. Tablet/Mobile Nav Menu */
@media screen and (max-width: 1200px) {
body {
padding-top: 5.9em; /* is not covered by menu bar */
}
.desktop-menu {
padding: 0; /* Stops mobile nav from jumping up when mobile icon is clicked */
}
.desktop-link {
text-align: left;
}
#mobile-menu {
background: #002147;
display: block; /* Shows mobile-menu on small screen menu */
position: absolute;
width: 100%;
}
#mobile-icon-container {
background: none;
float: right;
width: .35em;
}
/* 3.1 Tablet/Mobile Home2 Link */
#home {
display: none; /* 연세대학교 desktop-link disappears from small screen menu */
}
#mobile-menu #home2 { /* Inherits from "Styles for mobile menu icon" */
background: none;
border: 1px solid #fff;
font-size: .8em;
left: 1em;
position: absolute;
top: 1em;
}
.yonsei-logo {
float: left;
margin-bottom: -.5em;
margin-left: -.5em;
margin-right: .5em;
}
#logo-text {
font-size: 1.25em;
position: relative;
top: .5em;
}
#mobile-icon {
height: 3.5em;
margin-top: -.75em;
position: relative;
right: 1em;
top: .35em;
width: 2.5em;
}
/* 3.2 Tablet/Mobile Dropdown Menu */
a.caret { /* a.caret to beat specificity of styles for general a links */
background: #193658;
border-bottom: 1px solid #002147;
border-left: 1px solid #002147;
bottom: 0;
color: #fff;
display: block; /* Shows caret link on small screen menu */
position: absolute;
right: 0;
top: 0;
}
.caret:hover,
.caret:focus,
.caret:active {
background: #3277ae;
}
.desktop-link {
border-top: 1px solid #193658;
display: none; /* Javascript menu is removed when mobile menu is inactive */
font-size: .85em;
margin-top: 0;
}
.desktop-link:hover .dropdown-menu {
display: none; /* Makes dropdown menu disappear on small screens. AFFECTS ".desktop-link:hover .caretDropdown" ! */
}
#last-desktop-link {
border-bottom: 1px solid #002147;
}
/* 3.3 Tablet/Mobile Javascript Onclick Menu */
.responsive {
padding: 0;
position: absolute; /* Allows scrolling */
}
.responsive .desktop-link {
background: #002147;
display: block; /* Javascript menu is shown when mobile menu is active */
width: 100%;
position: relative;
top: 7em; /* Vertically aligns menu items */
z-index: 1; /* Allows mobile menu to show over slider */
}
.caretDropdown {
display: block;
width: 100%;
position: relative;
}
.desktop-link:hover .caretDropdown {
display: block; /* Allows dropdown menu to remain on screen when other mobile menu items are hovered. AFFECTED BY ".desktop-link:hover .dropdown-menu"! */
}
}
/* Toggle between adding and removing the "responsive" class to main menu when mobile menu icon is clicked */
function responsiveMenu() {
var x = document.getElementById("desktopMenu");
if (x.className === "desktop-menu") {
x.className += " responsive";
} else {
x.className = "desktop-menu";
}
}
/* Toggle between adding and removing the "caretDropdown" class to mobile menu links when caret link are clicked */
function caretDropdownOne() {
var caretDropdown1 = document.getElementById("caretDropdownOne");
if (caretDropdown1.className === "dropdown-menu") {
caretDropdown1.className += " caretDropdown";
} else {
caretDropdown1.className = "dropdown-menu";
}
}
function caretDropdownTwo() {
var caretDropdown2 = document.getElementById("caretDropdownTwo");
if (caretDropdown2.className === "dropdown-menu") {
caretDropdown2.className += " caretDropdown";
} else {
caretDropdown2.className = "dropdown-menu";
}
}
function caretDropdownThree() {
var caretDropdown3 = document.getElementById("caretDropdownThree");
if (caretDropdown3.className === "dropdown-menu") {
caretDropdown3.className += " caretDropdown";
} else {
caretDropdown3.className = "dropdown-menu";
}
}
function caretDropdownFour() {
var caretDropdown4 = document.getElementById("caretDropdownFour");
if (caretDropdown4.className === "dropdown-menu") {
caretDropdown4.className += " caretDropdown";
} else {
caretDropdown4.className = "dropdown-menu";
}
}
function caretDropdownFive() {
var caretDropdown5 = document.getElementById("caretDropdownFive");
if (caretDropdown5.className === "dropdown-menu") {
caretDropdown5.className += " caretDropdown";
} else {
caretDropdown5.className = "dropdown-menu";
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.