如何将引导程序下拉菜单按钮放置在右侧站点的页面标题中?

时间:2019-05-02 13:13:58

标签: html css twitter-bootstrap-3

这种情况看似很简单,但是我不能处理设置元素。

我所拥有的:

What I have

或:

bad

我需要什么

button on the right

代码: JSFiddle

<div class="container">

  <div class="page-header">
    <h2>Header</h2>

    <div class="btn-group <!-- pull-right -->">
        <a class="btn btn-success" href="/Scope/New">Create</a>
        <div class="btn-group">
            <button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu pre-scrollable" role="menu">
                <li class="dropdown-header">Create as copy: </li>
                    <li><a href="/Scope/New/1">Test 1</a></li>
                    <li><a href="/Scope/New/2">Test 45</a></li>
                    <li><a href="/Scope/New/3">Lorem ipsum</a></li>
            </ul>
        </div>
    </div>
  </div>
</div>

3 个答案:

答案 0 :(得分:1)

$args = array( 'post_type' => 'product', 'post_status' => 'any', 'orderby' => 'title', 'order' => 'ASC' ); if ( ! empty( get_queried_object() ) ) { $args['tax_query'] = array( array( 'taxonomy' => 'product_categorie', 'field' => 'slug', 'terms' => get_queried_object()->slug ), ); } 添加到clearfix

page-header

<div class="page-header clearfix">

答案 1 :(得分:1)

clearfix中添加page-header,并将display: inline;添加到h2
这样可以解决您的问题。 (当前h2已内联添加,您可以将其放在CSS文件中)

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">

  <div class="page-header clearfix
  ">
    <h2 style="display: inline;">Header</h2>

    <div class="btn-group <!-- pull-right -->">
      <a class="btn btn-success" href="/Scope/New">Create</a>
      <div class="btn-group">
        <button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
                <span class="caret"></span>
            </button>
        <ul class="dropdown-menu pre-scrollable" role="menu">
          <li class="dropdown-header">Create as copy: </li>
          <li><a href="/Scope/New/1">Test 1</a></li>
          <li><a href="/Scope/New/2">Test 45</a></li>
          <li><a href="/Scope/New/3">Lorem ipsum</a></li>
        </ul>
      </div>
    </div>
  </div>
</div>

答案 2 :(得分:0)

.page-header {
    padding-bottom: 9px;
    margin: 40px 0 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

<div class="container">
  <div class="page-header">
    <h2>Header</h2>
    <div class="btn-group">
        <a class="btn btn-success" href="/Scope/New">Create</a>
        <div class="btn-group">
            <button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu pre-scrollable" role="menu">
                <li class="dropdown-header">Create as copy: </li>
                    <li><a href="/Scope/New/1">Test 1</a></li>
                    <li><a href="/Scope/New/2">Test 45</a></li>
                    <li><a href="/Scope/New/3">Lorem ipsum</a></li>
            </ul>
        </div>
    </div>
  </div>
</div>

仅此而已,您可以使用flex。