white spaces on the all sides

时间:2015-06-06 作者:rendell

我是wordpress的新手,这是我转换的第一个html网站。在我将页面转换为wordpress主题后,我注意到页面的所有侧面都有一个空白。这只发生在转换之后,因为我的原始html页面没有空格。我有*{填充:0;边距:0;}在我的css上,但在wordpress上似乎不起作用。

标题。php

 <?php
/**
 * The template for displaying the header
 *
 *
 * @package WordPress
 * @subpackage Twenty_Fifteen
 * @since Twenty Fifteen 1.0
 */
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Theme</title>
<meta charset="<?php bloginfo( \'charset\' ); ?>">
<meta name="viewport" content="width=device-width">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( \'pingback_url\' ); ?>">
<link rel="stylesheet" href="<?php bloginfo(\'stylesheet_url\'); ?>" type="text/css"     
media="screen" />
<?php wp_head(); ?>
</head>
<?php 

if(is_home()):
    $awesome_classes = array(\'awesome-class\', \'my-class\');
else:
    $awesome_classes = array(\'no-awesome-class\');
endif;

?>
<body <?php body_class($awesome_classes); ?>>

<div class="container">
    <h2 class="logo">MY WEBSITE</h2>
    <?php wp_nav_menu(array(\'theme_location\'=>\'primary\')); ?>
页脚。php

</div>
<footer class="thefooter">
<p>Copyright 2015 My Website - All Rights Reserved</p>
<?php //wp_nav_menu(array(\'theme_location\'=>\'secondary\')); ?>
</footer>
<?php wp_footer(); ?>
</body>
</html>
样式。css

/*
Theme Name: My Theme
Theme URL: wordpress.com/index.php
Author: Rendell Lasola
Description: This is an awesome theme
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, white, responsive, one-column, two-columns, featured-images,  
custom-menu, custom-header, post-formats 
*/
*{
padding: 0;
margin: 0;
font-family: Arial;
list-style-type: none;
}

.container{
width: 100%;
max-width: 1020px;
margin: auto;
}

h1,.widget-title{
display: none;
}

h2.logo{
float: left;
font-family: Azedo;
font-size: 2em;
padding: 10px;
}

#menu-navigation{
float: right;
padding: 10px;
}


#menu-navigation li{
display: inline-block;
font-weight: bold;
padding: 15px; 
}

#menu-navigation li a{
text-decoration: none;
font-family: Arial;
font-weight: bold;
color: #2C3E50;
-webkit-transition: 0.4s all;
-moz-transition: 0.4s all;
-ms-transition: 0.4s all;
-o-transition: 0.4s all;
transition: 0.3s all;
}

#menu-navigation li a:hover{
color: #1E8BC3;
}

.container .jumbotron{
background: url(\'images/Jumbotron-wallpaper.png\');
width: 1020px;
max-width: 100%;
height: 431px;
clear: both;
}

.container .content{
text-align: center;
font-family: Arial;
color: #22313f;
}

.container .content h2{
 padding: 20px;
 }

.container .content article{
width: 284px;
margin: 0 auto;
display: inline-block;
vertical-align: top;
padding: 10px
}

.container .content article aside h4{
padding: 10px;
font-size: 1.5em;
}

.container .content article aside p{
width: 100%;
text-align: justify;
padding-top: 10px;
font-weight: bold;
}

.thefooter{
background: #22313f;
min-height: 75px;
margin-top: 75px;
text-align: center;
}

.thefooter p{
padding: 28px;
font-family: Arial;
font-weight: bold;
color: #FFF;
}

@media(min-width: 240px) and (max-width: 768px){

h2.logo{
    float: none;
    text-align: center;
}

#menu-navigation{
    float: none;
    text-align: center;
}

#menu-navigation li{
    display: block;
}

.container .jumbotron{
    background-position: 50%;
}

}
enter image description here

3 个回复
最合适的回答,由SO网友:rendell 整理而成

所以我通过添加body{padding:0!important;margin:0!important}来解决这个问题。不知道有什么东西覆盖了我的*{填充:0;边距:0;}。此外,忘了提到页脚不属于最大宽度为1020px的包装内;因为我的psd文件具有相同的宽度。

SO网友:Ace

css文件清楚地显示最大宽度为1020px,看起来就像缩小了屏幕一样,或者只是在屏幕截图的大屏幕上。如果你的窗口大于1020px,那么很明显,两边都会有空白。

.container{
  width: 100%;
  max-width: 1020px;
  margin: auto;
}
还需要注意的是,这不是wordpress的问题

SO网友:Rahul S

你能在css文件中给出这个以避免空格吗

html,正文{边距:0;填充:0;}

也是的,容器的最大宽度为1020px。

结束

相关推荐