dousi6192 2016-08-03 23:53
浏览 84
已采纳

当它应该是内联时,在标题之上的Wordpress身体

Here is a codepen to see the code I have written and works.

When I write similar code in my wordpress theme, my body appears above the header. How can I get the body next to the header?

[BONUS] What is the best way/how to align the body centered between the right-edge of the header and the right side of the screen.

Any advice is highly appreciated, and I thank you in advance.

[EDIT]: I changed my code for my wordpress site because before I was targeting body with css like I did in my codepen, but instead I created a div with class .site and am using that as the body. This is a temporary fix, but it is working as intended. How could I better achieve this affect so I can integrate visual plugin builders such as beaver builder?

HTML:

<div id="header">
  <img src="http://placehold.it/100x100">

    <ul id="nav">
      <li>Item 1</li>
      <li>Item 2</li>
      <li>Item Number 3</li>
      <li>Item #4</li>
    </ul>

</div>
<div id="body">
  <div id="container">Body
  </div>
  </div>

</div>

CSS:

#header,
#body {
  display: inline-block;
}

#header {
    white-space: nowrap;
  width: 15%;
  height: 100%;
  float: left;
  text-align: right;
  position: fixed;
    //border: 1px solid green;
}

#header img {

}

#nav ul {
    list-style: none;
}
#nav  {
  position: absolute;
  bottom: 4%;
  right: 0;
}

#body {
  width: 80%;
  float: right;
    //border: 1px solid yellow;
}

#container {
  height: 10000px;
}

HEADER.PHP:

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>

    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url')?>" />
    <meta charset="<?php bloginfo('charset'); ?>">
    <meta name="viewport" content="width=device-width">
    <title><?php bloginfo('name'); ?></title>
        <?php wp_head(); ?>
</head>

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

    <!-- Site Header -->
<header class="site-header">
  <?php the_custom_logo(); ?>
        <?php wp_nav_menu(array('theme_location','Primary','menu_class'=>'main-navigation')); ?>
</header>
    <!-- /Site Header -->

<!-- Site Content -->
  • 写回答

1条回答 默认 最新

  • dtz8044 2016-08-04 04:11
    关注

    Part of the problem was that I had a php error in my functions.php. Also I changed the position of the site content to absolute and the site nav to fixed. I then set the width of the sidebar nav and site content. I also added a content loop to my header to create the content area. Both site nav and content are displayed inline-block.

    Everything now seems to be working.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?