wordpress wp nav menu() do not have style - php

I can't style my WordPress function correctly, and the sub-menu and menu are displayed together and on top of each other. I want to separate these two, what should I do? My codes are as follows:
i do not know about html vs css code please help me or if you have any details about nav menu in wordpress template so please Guide me
<?php wp_nav_menu( array( 'theme_location' => 'primary_menu', 'container' =>'', 'menu_class' =>'meno' ) ); ?>
<style>
.meno{
list-style-type: none;
padding-right:20px;
width:800px;
}
.meno li{
display: inline-block;
margin-left:50px;
border-radius: 5px 5px 5px 5px;
background-color: #fff;
padding:-3px ;
}
.meno li a {
display: block;
padding: 0;
text-decoration: none;
/* this is the width of the menu items */
line-height: 35px;
/* this is the hieght of the menu items */
/* list item font color */
text-align: center;
}
.meno li li a {
font-size: 80%;
width: 200px;
transition: all 0.2s;
}
.meno li:hover {
background: #e0d5d5;
border-radius: 5px 5px 5px 5px;
transition: all 0.4s;
box-shadow: 0 0.125rem 0.125rem -0.125rem rgba(31, 27, 45, 0.08), 0 0.25rem 0.75rem rgba(31, 27, 45, 0.08);
}
.meno ul {
padding: 0;
left: 0;
/* hides sublists */
width: 100px;
height: 100px;
transition: all 0.4s;
position: absolute;
display: none;
}
.meno li:hover ul ul {
display: none;
background: #493131;
transition: all 0.4s;
}
.meno li:hover ul {
position: relative;
display:block;
width: 200px;
height: auto;
}
/* shows sublist on hover */
.meno li li:hover ul {
display: block;
/* shows sub-sublist on hover */
margin-left: 200px;
/* this should be the same width as the parent list item */
margin-top: -35px;
/* aligns top of sub menu with top of list item */
background: #8a7c7c;
}
</style>

Related

How can I replace a hamburger menu to a default one in WordPress?

I'm using a built-in default WordPress theme called Scrawl for testing purposes. https://wordpress.org/themes/scrawl/
I was trying to edit the styles but nothing seems working. How can I replace a hamburger menu to a default horizontal navigation menu when viewing in desktop on WordPress? Any information would help!
#media screen and ( min-width: 1024px ) and (max-width: 1281px) {
.menu-toggle {
display: none;
}
.site-logo {
max-height: 100px;
}
.has-site-logo .main-navigation {
height: 100px;
}
.has-site-logo .main-navigation > div,
.has-site-logo .main-navigation > ul {
position: relative;
top: 50%;
-moz-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
.main-navigation {
font-size: 0.8125em;
line-height: 2.09231em;
clear: none;
float: right;
max-width: 50%;
text-align: right;
}
.main-navigation ul:first-child {
display: block;
}
.main-navigation ul li {
display: inline-block;
}
.main-navigation ul li:hover > ul,
.main-navigation ul li.focus > ul {
display: block;
opacity: 1;
visibility: visible;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.main-navigation ul a {
border-bottom: 0;
padding: 5px 0 5px 14px;
}
.main-navigation ul ul {
background: white;
border: 1px solid #eeeeee;
display: none;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
float: left;
opacity: 0;
padding: 0 7px;
position: absolute;
top: 27px;
left: 0;
text-align: left;
visibility: hidden;
z-index: 99999;
}
.main-navigation ul ul li {
border-bottom: 1px solid #eeeeee;
padding: 5px 5px 4px;
}
.main-navigation ul ul li:last-of-type {
border-bottom: 0;
}
.main-navigation ul ul li a {
line-height: 1.5;
padding: 5px;
width: 180px;
}
.main-navigation ul ul ul {
left: 100%;
top: 0;
}
.main-navigation ul ul li a,
.main-navigation ul ul ul li a,
.main-navigation ul ul ul ul li a {
padding-left: 5px;
}
}
Here's my attempt of adding CSS code in the Customizer. I successfully removed the hamburger icon but the links aren't showing up. I didn't see the html structure for the links after I added the code, I was trying to add menus on the menus section but nothing changes.

How can I make my WordPress Nav Links Show Up?

I was trying to replace the hamburger menu that is with this theme, I successfully removed the hamburger menu through editing the styles in the child theme. I added these code in my customizer but the my nav links doesn't show up. I wanted to make the nav links into a horizontal position just like the default menus. I would appreciate some help. Thank you! This is the code I added in my customizer:
#media screen and ( min-width: 1024px ) and (max-width: 1281px) {
.menu-toggle {
display: none;
}
.site-logo {
max-height: 100px;
}
.has-site-logo .main-navigation {
height: 100px;
}
.has-site-logo .main-navigation > div,
.has-site-logo .main-navigation > ul {
position: relative;
top: 50%;
-moz-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
.main-navigation {
font-size: 0.8125em;
line-height: 2.09231em;
clear: none;
float: right;
max-width: 50%;
text-align: right;
}
.main-navigation ul:first-child {
display: block;
}
.main-navigation ul li {
display: inline-block;
}
.main-navigation ul li:hover > ul,
.main-navigation ul li.focus > ul {
display: block;
opacity: 1;
visibility: visible;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.main-navigation ul a {
border-bottom: 0;
padding: 5px 0 5px 14px;
}
.main-navigation ul ul {
background: white;
border: 1px solid #eeeeee;
display: none;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
float: left;
opacity: 0;
padding: 0 7px;
position: absolute;
top: 27px;
left: 0;
text-align: left;
visibility: hidden;
z-index: 99999;
}
.main-navigation ul ul li {
border-bottom: 1px solid #eeeeee;
padding: 5px 5px 4px;
}
.main-navigation ul ul li:last-of-type {
border-bottom: 0;
}
.main-navigation ul ul li a {
line-height: 1.5;
padding: 5px;
width: 180px;
}
.main-navigation ul ul ul {
left: 100%;
top: 0;
}
.main-navigation ul ul li a,
.main-navigation ul ul ul li a,
.main-navigation ul ul ul ul li a {
padding-left: 5px;
}
}
This is how it looks like when I added the code. The hamburger disappears but my navs links won't show up and horizontally. I'm using the default Wordpress theme Scrawl for testing purposes.

Change Name of Text with CSS

I am trying to change the text from "Menu" to "Close Menu" when Menu is open. I have no idea how to do it.
This is my HTML:
<input type="checkbox" id="responsive-nav">
<label for="responsive-nav" class="responsive-nav-label">
<span>☰</span> Menu
</label>
<nav>
<ul>
<li>Download Apps</li>
<li>Download Manuals</li>
</ul>
</nav>
This is my CSS:
/* MENU */
/* hide the checkbox and the label */
input#responsive-nav,
label.responsive-nav-label {
display: none;
font-size: 15pt;
}
/* declarations for the not-responsove-menu */
nav {
width: 220px; /* Darüber laesst sich die breite des Aufklappmenue steuern */
margin-left: -10px;
background: black
}
nav ul {
padding: 0px;
margin-left: -10px;
margin-top: 43px;
}
nav a {
display: block;
background: #FFF;
text-decoration: none;
color: white;
font-size: 15pt;
}
nav ul li {
position: relative;
float: left;
list-style: none;
color: #FFF;
transition: 0.5s;
}
/* Declarations for the responsive menu 1680px */
#media screen and (max-width: 15360px) {
* {
font-size: 15pt;
}
label.responsive-nav-label {
position: relative;
display: block;
padding: 0px;
background: black;
cursor: pointer;
color: #fff;
}
nav {
position: absolute;
top: -9999px;
padding: 0px;
}
input#responsive-nav[type=checkbox]:checked ~ nav {
position: relative;
top: 0;
}
nav a:after {
display: none;
}
nav li {
float: none !important;
width: 100% !important;
border-bottom: none !important;
}
nav li a {
margin-bottom: 10px !important;
padding: 10px 20px !important;
background: black;
}
nav ul li:hover {
background: none;
}
nav ul li a:hover {
background: black;
color: #11BEE0
}
}
/* END OF MENU */
the easiest way to do this is to actually remove the word "Menu" from the actually html and add two data attributes to the menu that you want to toggle between
so your label would look like this
<label for="responsive-nav" class="responsive-nav-label" data-closed=" Menu" data-open=" Close Menu"><span>☰</span></label>
next you will have to toggle the content based on whether your checkbox is checked or not with 2 styles like this
/* toggle the menu text */
input#responsive-nav[type=checkbox]:checked ~ label.responsive-nav-label:after{
content: attr(data-open);
}
input#responsive-nav[type=checkbox] ~ label.responsive-nav-label:after{
content: attr(data-closed);
}
here is the complete code that you can test
/* hide the checkbox and the label */
input#responsive-nav,
label.responsive-nav-label {
content: "Menu Hide";
display: none;
font-size: 15pt;
}
/* declarations for the not-responsove-menu */
nav {
width: 220px; /* Darüber laesst sich die breite des Aufklappmenue steuern */
margin-left: -10px;
background: black;
}
nav ul {
padding: 0px;
margin-left: -10px;
margin-top: 43px;
}
nav a {
display: block;
background: #FFF;
text-decoration: none;
color: white;
font-size: 15pt;
}
nav ul li {
position: relative;
float: left;
list-style: none;
color: #FFF;
transition: 0.5s;
}
/* Declarations for the responsive menu 1680px */
#media screen and (max-width: 15360px) {
* {
font-size: 15pt;
}
label.responsive-nav-label {
position: relative;
display: block;
padding: 0px;
background: black;
cursor: pointer;
color: #fff;
}
nav {
position: absolute;
top: -9999px;
padding: 0px;
}
input#responsive-nav[type=checkbox]:checked ~ nav {
position: relative;
top: 0;
}
/* toggle the menu text */
input#responsive-nav[type=checkbox]:checked ~ label.responsive-nav-label:after{
content: attr(data-open);
}
input#responsive-nav[type=checkbox] ~ label.responsive-nav-label:after{
content: attr(data-closed);
}
nav a:after {
display: none;
}
nav li {
float: none !important;
width: 100% !important;
border-bottom: none !important;
}
nav li a {
margin-bottom: 10px !important;
padding: 10px 20px !important;
background: black;
}
nav ul li:hover {
background: none;
}
nav ul li a:hover {
background: black;
color: #11BEE0
}
}
/* END OF MENU */
<input type="checkbox" id="responsive-nav">
<label for="responsive-nav" class="responsive-nav-label" data-closed=" Menu" data-open=" Close Menu"><span>☰</span></label>
<nav>
<ul>
<li>Download Apps</li>
<li>Download Manuals</li>
</ul>
</nav>
There is a similar question to yours.
if you are insistent to replace text content with css, you can visit the link below.
How to change content on hover
otherwise it's highly recommended to use javascript instead of css to replace or toggle content.
$(document).on("click","#menu-label",function(){
var $this = $(this);
if ($this.text() === "Menu"){
$this.text("Close")
}else {
$this.text("Menu")
}
});
/* hide the checkbox and the label */
input#responsive-nav,
label.responsive-nav-label {
display: none;
font-size: 15pt;
}
/* declarations for the not-responsove-menu */
nav {
width: 220px; /* Darüber laesst sich die breite des Aufklappmenue steuern */
margin-left: -10px;
background: black
}
nav ul {
padding: 0px;
margin-left: -10px;
margin-top: 43px;
}
nav a {
display: block;
background: #FFF;
text-decoration: none;
color: white;
font-size: 15pt;
}
nav ul li {
position: relative;
float: left;
list-style: none;
color: #FFF;
transition: 0.5s;
}
/* Declarations for the responsive menu 1680px */
#media screen and (max-width: 15360px) {
* {
font-size: 15pt;
}
label.responsive-nav-label {
position: relative;
display: block;
padding: 0px;
background: black;
cursor: pointer;
color: #fff;
}
nav {
position: absolute;
top: -9999px;
padding: 0px;
}
input#responsive-nav[type=checkbox]:checked ~ nav {
position: relative;
top: 0;
}
nav a:after {
display: none;
}
nav li {
float: none !important;
width: 100% !important;
border-bottom: none !important;
}
nav li a {
margin-bottom: 10px !important;
padding: 10px 20px !important;
background: black;
}
nav ul li:hover {
background: none;
}
nav ul li a:hover {
background: black;
color: #11BEE0
}
}
/* END OF MENU */
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" id="responsive-nav">
<label for="responsive-nav" class="responsive-nav-label" ><span>☰</span> <span id="menu-label">Menu</span></label>
<nav>
<ul>
<li>Download Apps</li>
<li>Download Manuals</li>
</ul>
</nav>
Since you are already using the checkbox hack for your menu, we can use that to show and hide text inside the label, too.
Inside the label, we add two <span>'s with the according text:
<label for="responsive-nav" class="responsive-nav-label">
<span>☰</span>
<span class="open">Close Menu</span>
<span class="closed">Menu</span>
</label>
As we want "Close Menu" to initially be hidden, we add
.open {
display: none
}
to our CSS.
When the checkbox is checked (meaning the menu is visible), just hide "menu" and display "Close Menu":
input#responsive-nav[type=checkbox]:checked ~ .responsive-nav-label > .closed {
display: none;
}
input#responsive-nav[type=checkbox]:checked ~ .responsive-nav-label > .open {
display: inline;
}
Here's a jsfiddle with the working code.

Wordpress/CSS - Submenu hover dropdown styles added to navigation bar

I have a responsive navigation bar that I have added to a WordPress theme. But I would like a submenu drop-down to be added to my responsive navigation bar but im unsure how to do this. I am new to PHP and WordPress.
HTML
<?php
$args = array(
'theme_location' => 'primary'
);
?>
<?php wp_nav_menu( $args ); ?>
</ul>
Menu
</nav>
CSS
nav {
height: 40px;
width: 100%;
color: #fff;
background: #86c024;
font-size: 11pt;
position: relative;
}
nav ul {
padding: 0;
margin: 0 auto;
max-width:1000px;
width: 100%;
height: 40px;
}
nav li {
display: inline;
float: left;
}
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
nav a {
color: #fff;
display: inline-block;
width: auto;
text-align: center;
text-decoration: none;
line-height: 40px;
}
nav li a {
padding: 0 10px;
border-right: 1px solid #fff;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
nav li a:link, a:visited {
color: white
}
nav li:last-child a {
border-right: 0;
}
nav a:hover {
background: #2098d1;
}
nav ul li.current-menu-item a:link,
.site-header nav ul li.current-menu-item a:visited,
.site-header nav ul li.current-page-ancestor a:link,
.site-header nav ul li.current-page-ancestor a:visited {
font-weight: bold;
background: #2098d1;
}
nav a#pull {
display: none;
}
#media screen and (max-width: 600px) {
nav {
height: auto;
}
nav ul {
width: 100%;
display: block;
height: auto;
}
nav li {
width: 100%;
float: left;
position: relative;
}
nav li a {
border-bottom: 1px solid #fff;
border-right: 1px solid #fff;
}
nav a {
text-align: left;
width: 100%;
text-indent: 25px;
}
}
#media only screen and (max-width : 600px) {
nav {
border-bottom: 0;
}
nav ul {
display: none;
height: auto;
}
nav a#pull {
display: block;
background: #86c024;
width: 100%;
position: relative;
}
nav a#pull:after {
content:"";
background: url('img/nav-icon.png') no-repeat;
width: 30px;
height: 30px;
display: inline-block;
position: absolute;
right: 15px;
top: 10px;
}
}
#media only screen and (max-width : 320px) {
nav li {
display: block;
float: none;
width: 100%;
}
nav li a {
border-bottom: 1px solid #576979;
}
}
Javascript
<script>
$(function() {
var pull = $('#pull');
menu = $('nav ul');
menuHeight = menu.height();
$(pull).on('click', function(e) {
e.preventDefault();
menu.slideToggle();
});
$(window).resize(function(){
var w = $(window).width();
if(w > 320 && menu.is(':hidden')) {
menu.removeAttr('style');
}
});
});
</script>
additional CSS attempt
ul.sub-menu { /* this targets all sub menus */
display: none; /* hide all sub menus from view */
position: absolute;
z-index: 10;
top: 40px; /* this should be the same height as the top level menu -- height + padding + borders */
}
ul.sub-menu li { /* this targets all submenu items */
width: 100px; /* set to the width you want your sub menus to be. This needs to match the value we set below */
}
ul.sub-menu li a { /* target all sub menu item links */
padding: 5px 10px; /* give our sub menu links a nice button feel */
}
ul.sub-menu li:hover {
display: block; /* show sub menus when hovering over a parent */
}
I have adjust some of your css and html, please check its working now.
the main problem is in the height of nav also I have change the position of a#pull to the top of the ul.
$(function() {
var pull = $('#pull');
menu = $('nav ul');
menuHeight = menu.height();
$(pull).on('click', function(e) {
e.preventDefault();
menu.slideToggle();
});
$(window).resize(function() {
var w = $(window).width();
if (w > 320 && menu.is(':hidden')) {
menu.removeAttr('style');
}
});
});
nav {
width: 100%;
color: #fff;
background: #86c024;
font-size: 11pt;
position: relative;
height: 100%;
overflow: hidden;
}
nav ul {
padding: 0;
margin: 0 auto;
max-width: 1000px;
width: 100%;
}
nav li {
display: inline;
float: left;
height: 40px;
}
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
nav a {
color: #fff;
display: inline-block;
width: auto;
text-align: center;
text-decoration: none;
line-height: 40px;
}
nav li a {
padding: 0 10px;
border-right: 1px solid #fff;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
nav li a:link,
a:visited {
color: white
}
nav li:last-child a {
border-right: 0;
}
nav a:hover {
background: #2098d1;
}
nav ul li.current-menu-item a:link,
.site-header nav ul li.current-menu-item a:visited,
.site-header nav ul li.current-page-ancestor a:link,
.site-header nav ul li.current-page-ancestor a:visited {
font-weight: bold;
background: #2098d1;
}
nav a#pull {
display: none;
}
#media screen and (max-width: 600px) {
nav {
height: auto;
}
nav ul {
width: 100%;
display: block;
height: auto;
}
nav li {
width: 100%;
float: left;
position: relative;
}
nav li a {
border-bottom: 1px solid #fff;
border-right: 1px solid #fff;
}
nav a {
text-align: left;
width: 100%;
text-indent: 25px;
}
}
#media only screen and (max-width: 600px) {
nav {
border-bottom: 0;
}
nav ul {
display: none;
height: auto;
}
nav a#pull {
display: block;
background: #86c024;
width: 100%;
position: relative;
}
nav a#pull:after {
content: "";
background: url('img/nav-icon.png') no-repeat;
width: 30px;
height: 30px;
display: inline-block;
position: absolute;
right: 15px;
top: 10px;
}
}
#media only screen and (max-width: 320px) {
nav li {
display: block;
float: none;
width: 100%;
}
nav li a {
border-bottom: 1px solid #576979;
}
}
}
<nav>
Menu
<ul>
<li>Home
</li>
<li>Home
</li>
<li>Home
</li>
<li>Home
</li>
<li>Home
</li>
</ul>
</nav>

Centering menu in header [duplicate]

This question already has answers here:
Centering a css dropdown menu
(2 answers)
Closed 8 years ago.
How can I center the menu/navigation in header?
PHP file looks like this
<div class="menu-and-contact-wrap">
<?php
$header_phone = get_option('theme_header_phone');
if( !empty($header_phone) ){
echo '<h2 class="contact-number"><i class="fa fa-phone"></i>'.$header_phone.' <span class="outer-strip"></span></h2>';
}
?>
<!-- Start Main Menu-->
<nav class="main-menu">
<?php
wp_nav_menu( array(
'theme_location' => 'main-menu',
'menu_class' => 'clearfix'
));
?>
</nav>
<!-- End Main Menu -->
</div>
And CSS file looks like this
.menu-and-contact-wrap {
padding: 0;
margin: 0;
width: 100%;
text-align: center;
}
.main-menu {
margin-top: 42px;
padding: 0;
margin: 0;
width: 100%;
text-align: center;
}
.main-menu ul {
list-style: none;
margin: 0;
}
.main-menu ul li {
float: left;
position: relative;
}
.main-menu ul li.current-menu-ancestor > a, .main-menu ul li.current-menu-parent > a, .main-menu ul li.current-menu-item > a, .main-menu ul li.current_page_item > a, .main-menu ul li:hover > a {
color: white;
background-color: #ec894d;
}
.main-menu ul li a {
font-family:"Lato", Helvetica, Arial, sans-serif;
color: #afb4b5;
font-size: 14px;
display: block;
text-decoration: none;
padding: 14px 10px;
}
.main-menu ul li ul {
display: none;
background-color: #ec894d;
width: 220px;
padding: 0;
position: absolute;
top: 48px;
left: 0;
z-index: 888;
}
.main-menu ul li ul li {
float: none;
margin: 0;
}
.main-menu ul li ul li:hover > a {
background-color: #dc7d44;
}
.main-menu ul li ul li a {
font-size: 13px;
padding: 10px 10px 12px;
color: white;
}
.main-menu ul li ul li ul {
background-color: #dc7d44;
top: 0px;
left: 220px;
}
.main-menu ul li ul li ul li:hover > a {
background-color: #d0743d;
}
.main-menu .responsive-nav {
display: none;
margin: 0px auto;
width: 100%;
padding: 5px;
}
I tried to change them as you can see above in CSS, but without any success
In default they looked like this:
Menu-and-contact-wrap looked like this
position: absolute;
bottom: 0;
right: 0;
And Main-menu looked like this before
margin-top: 42px;
float: right;
Thank you!
There are a few ways. Here are two.
Set a non-100% width on .main-menu and then add margin: 0 auto
Remove the floats from .main-menu ul li, add display: inline-block to it and add text-align: center to .main-menu

Categories