Okay, so will confess to being completely new at this. I am a designer, first and foremost and trying to learn how to code by dismantling pre-built templates and studying them.
What I want to do is - have a short line of text (left float), a centered logo (whose width / height may vary upon finalization), and a text nav (right float). I am modifying a theme.
Here is what I have:
<header id="header" class="wrapper<?php if (get_option($prefix.'_width') == "width_full") { ?>_full<?php } ?>">
<div class="header_top clearfix">
<div id="logo" class="left_float">
<a class="logotype" href="index.php"><img src="<?php echo get_option($prefix.'_logo', 'images/logo.png'); ?>" alt="Logotype"></a>
</div>
<?php if(function_exists('wp_nav_menu')) : ?>
<?php
wp_nav_menu(
array(
'theme_location' => 'primary-menu',
'container' => 'nav',
'container_id' => 'nav',
'container_class' => 'right_float',
'menu_class' => '',
'menu_id' => '' ,
'walker' => new custom_menu_output()
));
?>
<?php else: ?>
<nav id="nav" class="right_float">
<ul>
<?php wp_list_pages('title_li=&depth=0'); ?>
</ul>
</nav>
<?php endif; ?>
</div>
Below is the CSS. I've tried to interchange the .left_float with the .center class as a test, but it ends up pushing the nav downwards.
.left_float {
float: left;
}
.center {
display: block;
margin-left: auto;
margin-right: auto }
.right_float {
float: right;
}
Long post - sorry! Any help would be appreciated - even some links where I can read and learn and get started on my own.
Thanks a bunch!
Part 1: First of all, there is no <div> with class center in your code. Start off by putting all of your code that's between the left_float and right_float <div> tags into its own <div class="center">...</div> tag. I'm assuming you want something like:
<header id="header" class="wrapper<?php if (get_option($prefix.'_width') == "width_full") { ?>_full<?php } ?>">
<div class="header_top clearfix">
<div id="logo" class="left_float">
<a class="logotype" href="index.php"><img src="<?php echo get_option($prefix.'_logo', 'images/logo.png'); ?>" alt="Logotype"></a>
</div>
<div class="center">
<?php if(function_exists('wp_nav_menu')) : ?>
<?php
wp_nav_menu(
array(
'theme_location' => 'primary-menu',
'container' => 'nav',
'container_id' => 'nav',
'container_class' => 'right_float',
'menu_class' => '',
'menu_id' => '' ,
'walker' => new custom_menu_output()
));
?>
<?php else: ?>
</div>
<nav id="nav" class="right_float">
<ul>
<?php wp_list_pages('title_li=&depth=0'); ?>
</ul>
</nav>
<?php endif; ?>
</div>
<br clear="all" />
You'll notice I added <div class="center">...</div> and added <br clear="all" /> (which is important for the next part...)
Part 2: Change your CSS to:
.left_float, .center, .right_float {
float: left;
}
But make sure you keep the new <br clear="all" /> in your code! With that at the end, you can float all divs to the left, and they will all be beside each other. From there, you can modify the width of each of the divs to whatever you'd like!
Well, I hope that helps,
Hope4You
Your wp_nav_menu is without any div. Enclose is withing a div and add just a single class class=lfloat to all the three divs.
`.lfloat{
float: left;
}`
Related
Wordpress menu is adding several additiom and empty a tags (exacly two)
if (has_nav_menu('secondary')) :
?>
<nav id="menu-secondary-title" class="nav-anchors">
<div class="wrap">
<a id="menu-secondary-anchor" class="menu-secondary-anchor" title="<?php _e('Secondary Mobile Menu', 'path'); ?>" href="#menu-secondary-mobile"><?php //_e( 'Check Us Out!', 'path' ); ?></a>
<div id="mobile-menu-secondary">
<img src="<?php echo get_template_directory_uri(); ?>/images/Hamburger_icon.svg.png"
<?php wp_nav_menu(array('theme_location' => 'secondary', 'container_class' => 'menu-secondary-mobile-top', 'menu_class' => '', 'menu_id' => 'menu-secondary-items', 'fallback_cb' => '')); ?>
</div>
</div><!-- .wrap -->
</nav><!-- #menu-secondary-title -->
<nav id="menu-secondary" class="menu-container">
<div class="wrap clr">
<?php wp_nav_menu(array('theme_location' => 'secondary', 'container_class' => 'menu', 'menu_class' => '', 'menu_id' => 'menu-secondary-items', 'fallback_cb' => '')); ?>
</div><!-- .wrap -->
</nav><!-- #menu-secondary .menu-container -->
<?php endif; ?>
Please, help me find where could be something wrong. Which which next wordpress file can I explore, to find where is problem?
I am having problems reducing and/or removing the black space at the bottom of my wordpress webpage. Using inspector the black space seems to go over 2 css divs.
I need to add code in the custom css area to solve this but I dont know what to add.
http://andrewt.com.au/wp1/
this is the footer.php code
<?php
/**
* The template for displaying the footer
*
* Contains the closing of the #content div and all content after
*
* #package WordPress
* #subpackage Twenty_Sixteen
* #since Twenty Sixteen 1.0
*/
?>
</div><!-- .site-content -->
<footer id="colophon" class="site-footer" role="contentinfo">
<?php if ( has_nav_menu( 'primary' ) ) : ?>
<nav class="main-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Footer Primary Menu', 'twentysixteen' ); ?>">
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'menu_class' => 'primary-menu',
) );
?>
</nav><!-- .main-navigation -->
<?php endif; ?>
<?php if ( has_nav_menu( 'social' ) ) : ?>
<nav class="social-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Footer Social Links Menu', 'twentysixteen' ); ?>">
<?php
wp_nav_menu( array(
'theme_location' => 'social',
'menu_class' => 'social-links-menu',
'depth' => 1,
'link_before' => '<span class="screen-reader-text">',
'link_after' => '</span>',
) );
?>
</nav><!-- .social-navigation -->
<?php endif; ?>
</footer><!-- .site-footer -->
</div><!-- .site-inner -->
</div><!-- .site -->
<?php wp_footer(); ?>
</body>
</html>
Add this code in your footer.php
<?php
/**
* The template for displaying the footer
*
* Contains the closing of the #content div and all content after
*
* #package WordPress
* #subpackage Twenty_Sixteen
* #since Twenty Sixteen 1.0
*/
?>
<style>
#media screen and (min-width: 61.5625em){
.content-area .site-main {
margin-bottom: 0px;
}
}
</style>
</div><!-- .site-content -->
<footer id="colophon" class="site-footer" role="contentinfo">
<?php if ( has_nav_menu( 'primary' ) ) : ?>
<nav class="main-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Footer Primary Menu', 'twentysixteen' ); ?>">
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'menu_class' => 'primary-menu',
) );
?>
</nav><!-- .main-navigation -->
<?php endif; ?>
<?php if ( has_nav_menu( 'social' ) ) : ?>
<nav class="social-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Footer Social Links Menu', 'twentysixteen' ); ?>">
<?php
wp_nav_menu( array(
'theme_location' => 'social',
'menu_class' => 'social-links-menu',
'depth' => 1,
'link_before' => '<span class="screen-reader-text">',
'link_after' => '</span>',
) );
?>
</nav><!-- .social-navigation -->
<?php endif; ?>
</footer><!-- .site-footer -->
</div><!-- .site-inner -->
Your website is broken, or have very-very-very bad coded.
Add this css rules to custom css area( as you mentioned ):
#main{
margin-bottom: 10px;
}
footer{
padding: 5px; //or you can decrease/increase it
}
If after adding and refreshing/deleting cache of page, it doesn't affected, than try to use:
#main{
margin-bottom: 10px !important;
}
footer{
padding: 5px !important; //or you can decrease/increase it
}
or try to write the rules provided to some other stylesheet, such as default customizer of wordpress: Customize => Additional Css.
I am trying to make the toggler (hamburger) icon become an X.
I have followed another thread How to hide and replace navbar-toggler-icon in Bootstrap 4? and also used the code from Codeply
I can still not get the icon to changed. I am thinking something is wrong elsewhere.
Here is my nav code:
<div class="container">
<nav class="navbar navbar-toggleable-md navbar-light">
<div class="navbar-brand">
<?php if ( get_theme_mod( 'wp_bootstrap_starter_logo' ) ): ?>
<a href="<?php echo esc_url( home_url( '/' )); ?>">
<img src="<?php echo esc_attr(get_theme_mod( 'wp_bootstrap_starter_logo' )); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>">
</a>
<?php else : ?>
<a class="site-title" href="<?php echo esc_url( home_url( '/' )); ?>"><?php esc_url(bloginfo('name')); ?></a>
<?php endif; ?>
<button class="navbar-toggler navbar-toggler-center collapsed" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="bs4navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="my-1 mx-2 close">X</span>
<span class="navbar-toggler-icon"></span>
</button>
</div>
<?php
wp_nav_menu(array(
'theme_location' => 'primary',
'container' => 'div',
'container_id' => '',
'container_class' => 'collapse navbar-collapse justify-content-end',
'menu_id' => false,
'menu_class' => 'navbar-nav',
'depth' => 3,
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker()
));
?>
</nav>
</div>
And here is my CSS:
#media screen and (min-width: 200px) and (max-width: 998px){
.navbar-toggler {
display: block;
width: 100%;
float: none;
margin-right: 0;
}/*
.navbar-collapse.collapse {
display: none !important;
}*/
.navbar-header {float: none; text-align:center;}
nav.navbar-collapse.navbar-right.collapse.in {
display: block !important;
}
nav.navbar-collapse.navbar-right.collapse,
nav.navbar-collapse.navbar-right.collapse ul,
nav.navbar-collapse.navbar-right.collapse li,
nav.navbar-collapse.navbar-right.collapsing,
nav.navbar-collapse.navbar-right.collapsing ul,
nav.navbar-collapse.navbar-right.collapsing li {
width: 100%;
}
.navbar-toggler>.close {display:inline;}
.navbar-toggler.collapsed>.close,
.navbar-toggler:not(.collapsed)>.navbar-toggler-icon {display:none;}
.navbar-brand {margin:0 auto;}
#content .container {margin: 170px auto 0;}
}
I am not new to html, css, or php, but I am relatively new to BootStrap.
You will notice navbar-collapse is commented out and that is because it would immediately close the nav. That is an issue by itself. This is a child WordPress theme of wp-bootstrap-starter theme using BootStrap and UnderScores. Any help would be appreciated!
it is the CSS, it should be:
.navbar-toggler>.close {
display: inline;
}
.navbar-toggler.collapsed>.close,
.navbar-toggler:not(.collapsed)>.navbar-toggler-icon {
display: none;
}
I'm trying to make WordPress theme with the materialize framework but I'm really confused by the navbar part. I've searched on the internet but found nothing, it seems nobody works with materialize.
The only thing that I have found is to make it with nav_walker, like it is done in bootstrap but I don't know how to do it with materialize.
I have created a snippet that will allow you to create a navbar for wordpress with materializecss. However, it will not allow you to create children in the menu (dropdown bar). For this, you will need to create a customized nav walker.
The snippet and instructions can be found here:
https://github.com/kristofferandreasen/wp_materialize_navigation
It is based off the site vel linked to in the comments.
This should do the job:
<div class="m-container nav">
<div class="container">
<nav id="site-navigation" class="main-navigation" role="navigation">
<i class="mdi-navigation-menu"></i>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'menu side-nav', 'menu_id' => 'mobile-nav','items_wrap' => '<ul id="%1$s" class="%2$s"><li class="mobile-header"><p>Menu</p></li>%3$s</ul><div class="clear"></div>', ) ); ?>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'hide-on-med-and-down' ) ); ?>
</nav><!-- #site-navigation -->
<div class="clear"></div>
</div>
(Source: see the navigation part of this here: https://www.34sp.com/hosting-news/blog/wordpress-materialized-creating-material-design-theme-pt-1-theme-setup/)
I made this gist, a page index.php where I use the wordpress menu.
I don't believe this is the best solution but is a good start and works fine. Feel free to improve and use it as you wish.
https://gist.github.com/knoonrx/a27381877cfc9e4826fae28ec2544490
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php bloginfo('name') ?></title>
<link type="text/css" rel="stylesheet" href="<?= get_template_directory_uri(); ?>/css/materialize.min.css" media="screen,projection">
<link type="text/css" rel="stylesheet" href="<?= get_template_directory_uri(); ?>/style.css">
<style>
nav .sub-menu {
position: absolute;
min-width: 115px;
display: none;
transition: all .3s;
background-color: #ee6e73;
z-index: 1;
}
nav .sub-menu li {
white-space: nowrap;
float: none;
}
li.menu-item-has-children:hover > .sub-menu {
display: block;
}
</style>
</head>
<header>
<nav id="site-navigation" class="main-navigation" role="navigation">
<div class="nav-wrapper">
<div class="container">
Logo
<i class="mdi-navigation-menu"></i>
<?php
$menu = [ // mobile side menu array
'menu_class' => 'menu side-nav',
'menu_id' => 'mobile-nav',
'items_wrap' => '<ul id="%1$s" class="%2$s"><li class="mobile-header"><p>Menu</p></li>%3$s</ul><div class="clear"></div>',
];
wp_nav_menu( $menu ); // mobile side menu
$menu = [ // desktop menu array
'menu_class' => 'right hide-on-med-and-down'
];
wp_nav_menu( $menu ); // desktop menu
?>
</div>
</div>
</nav><!-- #site-navigation -->
<div class="clear"></div>
</header>
<br>
<br>
<body>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="<?= get_template_directory_uri(); ?>/js/materialize.min.js"></script>
<script>
$(document).ready(function () {
$(".button-collapse").sideNav();
});
</script>
</body>
</html>
Materialize CSS Wordpress Sub Menu
I can't figure out how to get a DIV to show up over a DIV that's underneath it. In other words, my webpage has a head, with a DIV that floats left and a DIV that floats right. Underneath that is a menu bar. I don't have many menu items, so I want image in the DIV that floats right to partially overlap the menu bar. I'm able to make it work with absolute positioning... but that not ideal. I went ahead and changed the width of the menu bar, but that's more of a temporary fix to get what I want. Thoughts?
www.sacspartans.org
<div id="page" class="hfeed site">
<header id="masthead" class="site-header" role="banner">
<div id="header-left">
<hgroup>
<h1 class="site-title">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<img src="http://sacspartans.org/wp-
content/uploads/2013/05/banner.png" alt="SacSpartans"
title="SacSpartans" border="0" />
</a>
</h1>
<h2 class="site-description"><?php bloginfo( 'description' ); ?>
</h2>
</hgroup>
</div>
<div id="header-right">
<img src="http://sacspartans.org/wp-
content/uploads/2013/05/california1.png" alt="MSU Alumni Club of
the Sacramento Valley" title="MSU Alumni Club of the Sacramento
Valley" border="0" />
</div>
<div id="navigation-bar">
<nav id="site-navigation" class="main-navigation" role="navigation">
<h3 class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></h3>
<a class="assistive-text" href="#content" title="<?php esc_attr_e(
'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to
content', 'twentytwelve' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary',
'menu_class' => 'nav-menu' ) ); ?>
</nav>
</div>
And now CSS info.
/* Header */
#header-left {
float: left;
}
#header-right {
float: right;
margin-top: 0;
}
#navigation-bar {
width: 575px;
}