Html WordPress定制

Html WordPress定制,html,css,wordpress,Html,Css,Wordpress,我正在建立我的第一个WordPress网站,我遇到了一点小麻烦。我有一个PHP脚本问题 我在网站上放了一个JavaScript幻灯片。我终于看到了这张照片。我面临的问题是,当我试图将此图像居中时。我几乎可以肯定这个图像包含在中。我希望有人能查看链接,然后告诉我出了什么问题 我不能发布CSS,因为它非常长。使用开发工具,您可以看到CSS。这可能是一个简单的问题,但我还是个新手 <?php /** * The Header template for our theme * * Displ

我正在建立我的第一个WordPress网站,我遇到了一点小麻烦。我有一个PHP脚本问题

我在网站上放了一个JavaScript幻灯片。我终于看到了这张照片。我面临的问题是,当我试图将此图像居中时。我几乎可以肯定这个图像包含在
中。我希望有人能查看链接,然后告诉我出了什么问题

我不能发布CSS,因为它非常长。使用开发工具,您可以看到CSS。这可能是一个简单的问题,但我还是个新手

<?php
/**
 * The Header template 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" />
<script type="text/javascript" src="java.js"></script>
<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 type="text/javascript" src="<?php bloginfo('template_url'); ?>java.js"></script>
<![endif]-->
<?php wp_head(); ?> 
</head>

<body <?php body_class(); ?>>
<div id="red"></div>
<div id="yellow"></div>
<div id="page" class="hfeed site leftBlueBorder">


        <img name="slide" class ="wrapper" id="slider main"><header id="masthead" class="site-header" role="banner">
        <hgroup><h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
            <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
        </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 -->

        <?php if ( get_header_image() ) : ?>
        <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php 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">
包装成一个div并对齐


您可以通过将文本对齐css属性设置为“中心”,将图像包装在div中,使其居中,例如更改:

.headSlider
{
    margin-left: auto; 
    margin-right: auto; 
    width: 875px;
}

致:


*您应该使用链接到类或id的css样式,而不是内联样式,这只是为了举例说明

此外,您的图像有多个id(slider和main)-html元素应该只有一个唯一的id


可能还有其他问题,但这超出了这个问题的范围

我将只对图像本身应用css来填充容器div:

<div style="text-align:center;">
    <img name="slide" class="wrapper" id="slider main">
</div>

注意:您正在使用非法的图像id值。。。它有一个空间。

谢谢。这是令人尴尬的简单。
img#slider {
  width: 100%;
  height: auto;
}
<div style="text-align:center;">
    <img name="slide" class="wrapper" id="slider main">
</div>
img#slider {
  width: 100%;
  height: auto;
}
img#slider {
   margin: 0 auto;
   display: block;
}