【发布时间】:2020-01-11 15:44:11
【问题描述】:
我正在创建我的第一个自定义 WordPress 主题。我在header.php 中调用wp_head(); 并在每一页中调用标题。这会导致正文顶部出现空白。为了摆脱这种情况,我在内容 div 的顶部和底部添加了 1px 填充。问题是这会导致每个页面滚动,无论它是否有足够的内容滚动。如果你没有登录,它是一个 2px 的滚动条。如果是,则为 2px 加上 wp 标头的高度。
我尝试过在 body 和 content div 上使用溢出设置,但似乎没有成功。
我也尝试设置内容 div position: absolute; overflow: auto。这在我注销时修复了它,但在我登录管理页面时添加了一个滚动条。
body {
margin: 0;
width: 100%;
background-color: rgb(255, 192, 203); //To highlight any white space.
}
.header {
width: 15vw;
height: 100vh;
padding: 0 1vw;
position: fixed;
background-color: rgb(51, 51, 51);
}
.content {
padding: 1px 0;
margin-left: 17vw;
background-color: rgb(20, 20, 20);
color: white;
min-height: 100vh;
}
<!--header.php-->
<body>
<?php wp_head(); ?>
<div class="header"></div>
<!--end header.php-->
<!--page.php-->
<?php get_header(); ?>
<div class="content">
All the page content goes here.
<div>
<?php get_footer(); ?>
<!--end page.php-->
<!--footer.php-->
<?php wp_footer(); ?>
</body>
<!--end footer.php-->
我希望页面没有足够的内容来保证滚动不滚动,同时还隐藏 wp 标题空白。有可能我做的事情都错了,所以任何建议都值得赞赏。
【问题讨论】:
标签: html css wordpress wordpress-theming