CSS/PHP code for center text in Header/Footer in style.css?
-
I’m a css/php beginner that I’m pulling my hair out. Basically, I’m stumped on style.css, but I’ll attach three files; style.css, header.php and footer.php are on here. My website is here: http://www.mtgrunt.com
/* (style.css) =02. Theme base -------------------------------------------------------------- */ /* Apply a natural box layout model to all elements */ *, *:before, *:after { box-sizing: border-box; } body { background-color: #f9f9f9; font-family: 'Roboto', sans-serif; font-size: 30px; font-weight: 300; line-height: 1.8; color: #757575; }
.tesseract-featured .entry-header { height: 100%; margin-left: auto; margin-right: auto; width: 90%; }
<?php /** * The header for our theme. (header.php) * * Displays all of the <head> section and everything up till <div id="content"> * * @package Tesseract */ ?><!DOCTYPE html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="profile" href="http://gmpg.org/xfn/11"> <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>"> <?php wp_head(); ?> </head> <?php // Additional body classes $bodyClass = ( version_compare($wp_version, '4.0.0', '>') && is_customize_preview() ) ? 'backend' : 'frontend'; if ( (is_page()) && (has_post_thumbnail()) ) $bodyClass .= ' tesseract-featured'; $opValue = get_theme_mod('tesseract_tho_header_colors_bck_color_opacity'); $header_bckOpacity = is_numeric($opValue) ? TRUE : FALSE; if ( is_front_page() && ( $header_bckOpacity && ( intval($opValue) < 100 ) ) ) $bodyClass .= ' transparent-header'; ?> <body <?php body_class( $bodyClass ); ?>> <nav id="mobile-navigation" class="top-navigation" role="navigation"> <?php $anyMenu = get_terms( 'nav_menu' ) ? true : false; $menuSelect = get_theme_mod('tesseract_tho_header_menu_select'); if ( $anyMenu && ( ( $menuSelect ) && ( $menuSelect !== 'none' ) ) ) : wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'header-menu' ) ); elseif ( $anyMenu && ( !$menuSelect || ( $menuSelect == 'none' ) ) ) : $menu = get_terms( 'nav_menu' ); $menu_id = $menu[0]->term_id; wp_nav_menu( array( 'menu_id' => $menu_id ) ); elseif ( !$anyMenu ) : wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); endif; ?> </nav><!-- #site-navigation --> <div id="page" class="hfeed site"> <a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'tesseract' ); ?></a> <a class="menu-open dashicons dashicons-menu" href="#mobile-navigation"></a> <a class="menu-close dashicons dashicons-no" href="#"></a> <header id="masthead" class="site-header <?php echo get_header_image() ? 'is-header-image' : 'no-header-image'; ?>" role="banner"> <?php $logoImg = get_theme_mod('tesseract_logo_image'); $blogname = get_bloginfo('blogname'); $headright_content = get_theme_mod('tesseract_tho_header_content_content'); $headright_content_default_button = get_theme_mod('tesseract_tho_header_content_if_button'); if ( !$logoImg && $blogname ) $brand_content = 'blogname'; if ( $logoImg ) $brand_content = 'logo'; if ( !$logoImg && !$blogname ) $brand_content = 'no-brand'; ?> <div id="site-banner" class="cf<?php echo ' ' . $headright_content . ' ' . $brand_content; echo ( ( $headright_content ) && ( $headright_content !== 'nothing' ) ) ? ' is-right' : ' no-right'; ?>"> <div id="site-banner-left" class="<?php echo ( ( $headright_content ) && ( $headright_content !== 'nothing' ) ) ? 'is-right' : 'no-right'; ?>"> <?php if ( $logoImg || $blogname ) { ?> <div class="site-branding"> <?php if ( $logoImg ) : ?> <h1 class="site-logo"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><img src="<?php echo $logoImg; ?>" alt="logo" /></a></h1> <?php else : ?> <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> <?php endif; ?> </div><!-- .site-branding --> <?php } ?> <nav id="site-navigation" class="main-navigation top-navigation" role="navigation"> <?php $anyMenu = get_terms( 'nav_menu' ) ? true : false; $menuSelect = get_theme_mod('tesseract_tho_header_menu_select'); if ( $anyMenu && ( ( $menuSelect ) && ( $menuSelect !== 'none' ) ) ) : wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'header-menu' ) ); elseif ( $anyMenu && ( !$menuSelect || ( $menuSelect == 'none' ) ) ) : $menu = get_terms( 'nav_menu' ); $menu_id = $menu[0]->term_id; wp_nav_menu( array( 'menu_id' => $menu_id ) ); elseif ( !$anyMenu ) : wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); endif; ?> </nav><!-- #site-navigation --> </div> <?php if ( $headright_content ) : ?> <div id="site-banner-right"> <?php tesseract_header_right_content($headright_content); ?> </div> <?php elseif ( !$headright_content && $headright_content_default_button ) : ?> <div id="site-banner-right"> <div id="header-button-container"> <div id="header-button-container-inner"> <?php echo $headright_content_default_button; ?> </div> </div> </div> <?php else : ?> <div id="site-banner-right"> <div id="header-button-container"> <div id="header-button-container-inner"> <a href="/" class="button primary-button">Primary Button</a> <a href="/" class="button secondary-button">Secondary Button</a> </div> </div> </div> <?php endif; ?> </div> </header><!-- #masthead --> <div id="content" class="cf site-content">
<?php /** * (footer.php) The template for displaying the footer. * * Contains the closing of the #content div and all content after * * @package Tesseract */ ?> </div><!-- #content --> <footer id="colophon" class="site-footer" role="contentinfo"> <?php $additional = get_theme_mod('tesseract_tfo_footer_additional_content') ? true : false; $menuClass = 'only-menu'; if ( $additional ) $menuClass = 'is-additional'; $menuEnable = get_theme_mod('tesseract_tfo_footer_content_enable'); $menuSelect = get_theme_mod('tesseract_tfo_footer_content_select'); $addcontent_hml = get_theme_mod('tesseract_tfo_footer_additional_content'); $addcontent_hml = $addcontent_hml ? $addcontent_hml : 'notset'; ?> <div id="footer-banner" class="cf<?php echo ' menu-' . $menuClass; ?>"> <div id="horizontal-menu-wrap" class="<?php echo $menuClass . ' ' . $addcontent_hml; ?>"> <?php // SHOUDLD some additional content added before the menu? if ( ( $addcontent_hml !== 'nothing' ) && ( $addcontent_hml !== 'notset' ) ) : ?> <div id="horizontal-menu-before" class="switch thm-left-left<?php if ( ( $menuEnable && ( $menuEnable == 1 ) ) || !$menuEnable ) echo ' is-menu'; ?>"><?php tesseract_horizontal_footer_menu_additional_content( $addcontent_hml ); ?></div> <?php endif; //EOF left menu - IS before content ?> <?php if ( ( $menuEnable && ( $menuEnable == 1 ) ) || !$menuEnable ) : ?> <section id="footer-horizontal-menu"<?php if ( $addcontent_hml && ( $addcontent_hml !== 'nothing' ) && ( $addcontent_hml !== 'notset' ) ) echo ' class="is-before"'; ?>> <div> <?php $anyMenu = get_terms( 'nav_menu' ) ? true : false; if ( $anyMenu ) : if ( $menuSelect !== 'none' ) : wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'footer-menu', 'depth' => 1 ) ); elseif ( ( $menuSelect == 'none' ) || !$menuSelect || !$menuEnable ) : $menu = get_terms( 'nav_menu' ); $menu_id = $menu[0]->term_id; wp_nav_menu( array( 'menu_id' => $menu_id ) ); endif; ?> <?php else : wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'depth' => 1 ) ); endif; ?> </div> </section> <?php endif; ?> </div><!-- EOF horizontal-menu-wrap --> <div id="designer"> <?php printf( __( '%s', 'tesseract' ), '<a href="http://mtgrunt.com"></a>©MTGRUNT'); ?> </div> </div> </footer><!-- #colophon --> </div><!-- #page --> <?php wp_footer(); ?> </body> </html>
-
You need to link us your site for this
If you’re not using a Child Theme, and if the theme doesn’t have a designated section of the dashboard for CSS modifications then install this Custom CSS Manager plugin http://wordpress.org/plugins/custom-css-manager-plugin
Then use its “CSS Code” section of the dashboard to hold your CSS modifications:
Alternatively use your Child Theme style.css file to hold your CSS modifications:
.top-navigation, footer-horizontal-menu { text-align: center; } .footer-menu, .footer-menu ul { float: none; }
Impressive, thank you Andrew. My header is center, but my footer is not. What to do with that? Thanks again for all your help!
Replace this:
footer-horizontal-menu
With this:
#footer-horizontal-menu
Thanks again, you solved it. I appreciate this, Andrew.
- The topic ‘CSS/PHP code for center text in Header/Footer in style.css?’ is closed to new replies.