Support » Developing with WordPress » How to convert html menu to WordPress menu

  • I deal with wordpress generally. However, I do not give here.
    I use underscores.me and want to replace the mobile menu. I removed the old one and add it.

    <button id="slowmo">Slow motion <span>mode</span></button>
    
    <div class="device">
    	<div class="container">
    		<button id="burger" class="open-main-nav">
    			<span class="burger"></span>
    			<span class="burger-text">Menu</span>
    		</button>
    		<nav class="main-nav" id="main-nav">
    			<ul>
    				<li>
    					<a href="#">About me</a>
    				</li>
    				<li>
    					<a href="#">Speaker & Writer</a>
    				</li>
    				<li>
    					<a href="#">Work</a>
    				</li>
    				<li>
    					<a href="#">Contact</a>
    				</li>
    				<li>
    					<a href="#">Blog</a>
    				</li>
    			</ul>
    		</nav>
    		<p class="notice">Design Copyright <strong>Stéphanie Walter</strong><br><a href="https://stephaniewalter.design/" target="_blank">StephanieWalter.Design</a></p>
    	</div>
    </div>
    /* Main menu positionning */
    .main-nav {
        position: absolute;
        top: 0;
        right: 0;
        left: 0;
        bottom: 0;
        text-align: center;
        background: #FFF;
        opacity: 0;
        z-index: -1;
        visibility: hidden;
        transition: all .375s;
    }
    
    .main-nav.is-open {
        opacity: 1;
        z-index: 100;
        visibility: visible;
    }
    
    /* Yellow band effect */
    .main-nav::before {
    	 content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: -15px;
        background: #FEDC2A;
        transform-origin: 0 0;
        transform: skew(-14deg) translateX(-120%);
        transition: all .275s .1s;
    }
    
    .main-nav.is-open::before {
        transform: skew(-14deg) translateX(0);
    }
    
    /* Skewing effect on menu links */
    .main-nav ul {
        display: inline-flex;
        flex-direction: column;
        height: 93%; /* Should be 100%, but we have a notice message :D */
        align-items: flex-end;
        justify-content: center;
        transform: translateX(-18%) skew(-16deg);
    }
    
    .main-nav li {
        display: block;
        margin: .5rem 0;
        text-align: right;
        transform: skew(16deg);
    }
    
    /* Apparition effect on links */
    .main-nav a {
        opacity: 0;
        transform: translateY(-10px);
    }
    
    .main-nav.is-open a {
        opacity: 1;
        transform: translateY(0);
    }
    .main-nav li:nth-child(1) a {
    	transition: all 275ms 175ms
    }
    .main-nav li:nth-child(2) a {
    	transition: all 275ms 225ms
    }
    .main-nav li:nth-child(3) a {
    	transition: all 275ms 275ms
    }
    .main-nav li:nth-child(4) a {
    	transition: all 275ms 325ms
    }
    .main-nav li:nth-child(5) a {
    	transition: all 275ms 375ms
    }
    
    /* Decoration */
    .main-nav ul,
    .main-nav li {
    	list-style: none;
    	padding: 0;
    }
    .main-nav a {
    	display: block;
    	padding: 12px 0;
    	color: #5A3B5D;
    	font-size: 1.4em;
    	text-decoration: none;
    	font-weight: bold;
    }
    
    /* Burger Style: @see: https://codepen.io/CreativeJuiz/full/oMZNXy */
    .open-main-nav {
    	position: absolute;
    	top: 15px;
    	padding-top: 20px;
    	right: 15px;
    	z-index: 1000;
    	background: none;
    	border: 0;
    	cursor: pointer;
    }
    .open-main-nav:focus {
    	outline: none;
    }
    .burger {
    	position: relative;
    	display: block;
    	width: 28px;
    	height: 4px;
    	margin: 0 auto;
    	background: #5A3B5D;
    	transform: skew(5deg);
    	transition: all .275s;
    }
    
    .burger:after,
    .burger:before {
    	content: '';
    	display: block;
    	height: 100%;
    	background: #5A3B5D;
    	transition: all .275s;
    }
    
    .burger:after {
    	transform: translateY(-12px) translateX(-2px) skew(-20deg);
    }
    
    .burger:before {
    	transform: translateY(-16px) skew(-10deg);
    }
    
    /* Toggle State part */
    .is-open .burger {
    	transform: skew(5deg) translateY(-8px) rotate(-45deg);
    }
    
    .is-open .burger:before {
    	transform: translateY(0px) skew(-10deg) rotate(75deg);
    }
    
    .is-open .burger:after {
    	transform: translateY(-12px) translateX(10px) skew(-20deg);
        opacity: 0;
    }
    
    /* MENU Text part */
    
    .burger-text {
    	display: block;
    	font-size: .675rem;
    	letter-spacing: .05em;
    	margin-top: .5em;
    	text-transform: uppercase;
    	font-weight: 500;
    	text-align: center;
    	color: #5A3B5D;
    }
    
    .device {
    	position: relative;
    	width: 345px;
    	height: 600px;
    	background: #FFF;
    	border: 1px solid #EEE;
    	border-radius: 3px;
    	box-shadow: 0 0 0 10px rgba(0,0,0,.1);
    }
    
    .container {
    	position: absolute;
    	top: 0; right: 0;
    	bottom: 0; left: 0;
    	overflow: hidden;
    	background: linear-gradient(to bottom, #eee, #ddd);
    }
    
    html {
    	height: 100%;
    }
    body {
    	height: 100%;
    	display: flex;
    	justify-content: center;
    	align-items: center;
    }
    
    /* Slow motion button */
    [id="slowmo"] {
    	position: absolute;
    	top: 20px;
    	right: 20px;
    	padding: 10px;
    	border: 0;
    	font-size: 1rem;
    	background: #FEDC2A;
    	color: #5A3B5D;
    	font-weight: bold;
    	cursor: pointer;
    	transition: all .275s;
    }
    
    [id="slowmo"] span {
    	display: block;
    	font-weight: normal;
    }
    
    [id="slowmo"]:hover,
    [id="slowmo"]:focus {
    	background: #5A3B5D;
    	color: #FEDC2A;
    }
    
    [id="slowmo"].is-slowmo span:after {
    	content: 'Activated';
    	display: block;
    	font-weight: bold;
    }
    
    /* When slowmotion is activated */
    
    .is-slowmo + .device .open-main-nav .burger,
    .is-slowmo + .device .open-main-nav .burger:before,
    .is-slowmo + .device .open-main-nav .burger:after,
    .is-slowmo + .device .main-nav,
    .is-slowmo + .device .main-nav::before,
    .is-slowmo + .device .main-nav a {
    	transition-duration: 3s;
    }
    .is-slowmo + .device .main-nav li:nth-child(1) a {
    	transition-delay: 1750ms
    }
    .is-slowmo + .device .main-nav li:nth-child(2) a {
    	transition-delay: 2250ms
    }
    .is-slowmo + .device .main-nav li:nth-child(3) a {
    	transition-delay: 2750ms
    }
    .is-slowmo + .device .main-nav li:nth-child(4) a {
    	transition-delay: 3250ms
    }
    .is-slowmo + .device .main-nav li:nth-child(5) a {
    	transition-delay: 3750ms
    }
    
    /* Notice */
    .notice {
    	position: absolute;
    	bottom: -15px;
    	left: 0; right: 0;
    	padding: 20px;
    	background: #F2F2F2;
    	color: #5A3B5D;
    	font-size: 14px;
    	font-weight: 400;
    	line-height: 1.5;
    	z-index: 100;
    	text-align: center;
    }
    .notice strong {
    	font-weight: 700;
    }
    .notice a {
    	padding: 2px 3px;
    	background: #FEDC2A;
    	text-decoration: none;
    }
    let burger = document.getElementById('burger'),
    	 nav    = document.getElementById('main-nav'),
    	 slowmo = document.getElementById('slowmo');
    
    burger.addEventListener('click', function(e){
    	this.classList.toggle('is-open');
    	nav.classList.toggle('is-open');
    });
    
    slowmo.addEventListener('click', function(e){
    	this.classList.toggle('is-slowmo');
    });
    
    /* Onload demo - dirty timeout */
    let clickEvent = new Event('click');
    
    window.addEventListener('load', function(e) {
    	slowmo.dispatchEvent(clickEvent);
    	burger.dispatchEvent(clickEvent);
    	
    	setTimeout(function(){
    		burger.dispatchEvent(clickEvent);
    		
    		setTimeout(function(){
    			slowmo.dispatchEvent(clickEvent);
    		}, 3500);
    	}, 5500);
    });

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • It’s much easier to go to Dashboard – Appearance – Menus and create your menu and then style it with Custom CSS if you don’t like the default styling.

Viewing 1 replies (of 1 total)
  • The topic ‘How to convert html menu to WordPress menu’ is closed to new replies.