【问题标题】:How to stop H1 from filling whole div如何阻止 H1 填充整个 div
【发布时间】:2019-08-07 03:34:41
【问题描述】:

我正在为我的 wordpress 创建一个主题。我正在尝试添加顶部菜单,但 h1 限制菜单位于同一行: 我希望它们位于同一行。

这是 HTML/PHP:

<header>
    <h1 class='title'><?php the_title(); ?></h1>    
    <?php wp_nav_menu(
        array(
            'theme_location' => 'top-menu',
            'menu_class' => 'topmenu'
        )
    );?>
</header>

这是 CSS:

.title {
    font-size: 1.5em;
    font-weight: bold;
    margin: 0;
}

header {
    width: 100%;
    padding: 25px;
    padding-left: 20%;
    padding-right: 20%;
}  

.topmenu {
    list-style-type: none;
    float: right;
    margin: 0;
    padding: 0;
}

.topmenu li {
    display: inline;
}

提前谢谢你!

【问题讨论】:

  • hx 元素是 100% 宽默认情况下....限制宽度或使它们 display:inline-block 等...不是。跨度>

标签: php html css wordpress-theming


【解决方案1】:

在你的 CSS 中使用它

h1 {
     display: inline-block;
}

【讨论】:

    猜你喜欢
    • 2019-08-04
    • 1970-01-01
    • 2013-11-10
    • 2012-07-29
    • 2011-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多