在我的大多数网站开发中,我都使用TwentyEleven作为父主题。
然而,当我更改与菜单相关的任何样式或位置时,菜单的响应特性不会在小屏幕上生效。相反,所有菜单项都显示在垂直列表中。
我所做的:
创建了一个新的子级TheMercreated标头。php通过复制粘贴原始标题中的内容。php文件,创建了一个样式。css并在此处添加样式替代。
然后我将站点导航div移到hgroup中,这样我就可以在顶部显示菜单,就在徽标之后。试图向添加一些边距。主导航和菜单不会回退到小屏幕上的响应布局。
这是菜单在小屏幕上的显示方式:
这是标题。php代码:
<?php
/**
* The Header for our theme.
*
* Displays all of the <head> section and everything up till <div id="main">
*
* @package WordPress
* @subpackage Twenty_Twelve
* @since Twenty Twelve 1.0
*/
?><!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 7) | !(IE 8) ]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( \'charset\' ); ?>" />
<meta name="viewport" content="width=device-width" />
<title><?php wp_title( \'|\', true, \'right\' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( \'pingback_url\' ); ?>" />
<?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<![endif]-->
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header id="masthead" class="site-header" role="banner">
<hgroup>
<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><!-- #site-navigation -->
<h1 class="site-title">
<a href="http://b2.mumacro.com/" title="Bennys Salon" rel="home">
<img class="fplogoimg" src="http://b2.mumacro.com/wp-content/uploads/2013/04/BennysLogoOnlyText.png"></img>
<h2 class="site-description"><?php bloginfo( \'description\' ); ?></h2>
</a>
</h1>
</hgroup>
<?php $header_image = get_header_image();
if ( ! empty( $header_image ) ) : ?>
<a href="<?php echo esc_url( home_url( \'/\' ) ); ?>"><img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
<?php endif; ?>
</header><!-- #masthead -->
<div id="main" class="wrapper">
样式。css:
/*
Theme Name: Bennys Salon
Description: Bennys Salon Child Theme
Author: MuMacro
Template: twentytwelve
(optional values you can add: Theme URI, Author URI, Version)
*/
@import url("../twentytwelve/style.css");
@import url(http://fonts.googleapis.com/css?family=Acme);
@import url(http://fonts.googleapis.com/css?family=PT+Sans:400,700italic);
/* Fonts */
.nav-menu{
font-family: Acme, serif;
color: #9C3F97;
text-transform:uppercase;
}
.entry-header .entry-title {
color: black;
font-size: 1.57143rem;
font-family: Acme, serif;
}
.entry-content p, .entry-summary p, .comment-content p, .mu_register p {
color: black;
line-height: 1.71429;
margin: 0 0 1.71429rem;
}
/*Navigation*/
.main-navigation li a {
border-bottom: 0 none;
color: #9C3F97;
font-size: 13px;
line-height: 3.69231;
text-transform: uppercase;
white-space: nowrap;
}
.main-navigation ul.nav-menu, .main-navigation div.nav-menu > ul {
border-bottom: 0 solid #EDEDED;
border-top: 0 solid #EDEDED;
display: inline-block !important;
margin-left: 28%;
margin-top: 0;
text-align: left;
width: 100%;
}
/* Header */
.site-header h2 {
color: #9C3F97;
font-size: 17px;
font-weight: normal;
line-height: 1.84615;
font-style: italic;
font-family: Acme;
}
.site-header h1 {
font-size: 1.85714rem;
line-height: 1.84615;
margin-left: -27px;
}
.site-header {
padding: 1% 0;
}
/*Navigation*/
.main-navigation {
margin-top: 0.714rem;
text-align: center;
}
/* Content Background */
.site{
background: rgba(255,255,255, .5); /* Works on all modern browsers */
}
body .site {
box-shadow: 37px 24px 51px rgba(205, 100, 100, 0.3);
margin-bottom: 3.42857rem;
margin-top: 3.42857rem;
padding: 0 2.85714rem;
}
/*Footer Credits*/
.site-info{
float:right;
}
/* Font Colors */
.site-header h2 {
color: #9C3F97;
font-size: 17px;
font-style: italic;
font-weight: normal;
line-height: 1.84615;
}
/* Logo Image */
.fplogoimg{
height:130px;
}
/* Site Description*/
.site-description {
margin-left: 5%;
position: relative;
}
/*Content Margins*/
.site-content {
margin: 0;
}
.widget-area {
margin: 0;
}
body .site {
box-shadow: 37px 24px 51px rgba(205, 100, 100, 0.3);
margin-bottom: 1.429rem;
margin-top: 1.429rem;
padding: 0 2.85714rem;
}
注意:我对HTML、CSS不太熟悉。我只是想办法破解一个解决方案。
请帮忙。