我想在Bootstrap中创建一个简单的水平放置两个下拉按钮,

到目前为止,这是我所做的:



label{
    font-size: 0.875rem;
    color: #666666;
    text-transform: uppercase;
    line-height: 1;
    margin-bottom: .5rem;
    display: block;
    display: flex;
    position: absolute;
}

.dropdown-select{

    width: 500px;
    border-bottom-color: deepskyblue;
    background-color: white;
    border-top: 0px;
    border-left: 0px;
    border-right: 0px;
        margin-right: 30px;
}

.dropdown-list{

    margin-top: 50px;
}

.btn-group>.btn-group:not(:first-child)>.btn, .btn-group>.btn:not(:first-child)
{
    border: none;
    color: green;
    background-color: white;
    margin-left: -22px;
    position: absolute;
    left: 532px
}

<div class="container>

<div class="row">


        <div class="btn-group dropdown-list">

        <label class="label-status">Test1</label>
            <button class="dropdown-select" type="button"
                    aria-haspopup="true" aria-expanded="false" data-toggle="dropdown">
               <input type="hidden" > demo
            </button>
            <button [disabled]="disabled" type="button" class="btn btn-lg btn-secondary dropdown-toggle dropdown-toggle-split"
                    data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <span class="sr-only">Toggle Dropdown</span>
            </button>
            <div class="dropdown-menu">
             <button class="dropdown-item" type="button">Action</button>
            </div>

            <label class="label-serv">Test1</label>
            <button class="dropdown-select" type="button"
                    aria-haspopup="true" aria-expanded="false" data-toggle="dropdown">
               <input type="hidden" > demo
            </button>
            <button [disabled]="disabled" type="button" class="btn btn-lg btn-secondary dropdown-toggle dropdown-toggle-split"
                    data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <span class="sr-only">Toggle Dropdown</span>
            </button>
            <div class="dropdown-menu">
             <button class="dropdown-item" type="button">Action</button>
            </div>



        </div>

</div>





上面的代码给了我这样的东西:
wrong view

我以不同的方式尝试过,

实际结果应类似于以下内容:
actual view

任何类似的例子,教程或帮助将不胜感激。

谢谢

最佳答案

这是我的示例,也许您可​​以使用其中的某些部分。
我按照您的“实际观点”准备了设计



.content{
  margin: 0;
  width: 100%;
}
span{
  font-size: 14px;
  color: #ccc;
}
.dropbtn {
    color: #333;
    padding: 5px 5px 5px 0px;
    font-size: 16px;
    cursor: pointer;
}
.dropbtn span{
  color: #62c2ea;
  float: right;
  transform: rotate(-90deg);
}
.dropdown {
    position: relative;
    display: inline-block;
    border-bottom: 2px solid #62c2ea;
    width: 40%;
    margin-right: 30px;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #fff;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    width: 100%;
    margin-top: 2px;
}

.dropdown-content a {
    color: black;
    padding: 16px 16px;
    text-decoration: none;
    display: block;
}

.dropdown-content a:hover {background-color: #f1f1f1}

.dropdown:hover .dropdown-content {
    display: block;
}

<div class="content">
  <div class="dropdown">
    <span>Specjalista</span>
    <div class="dropbtn">Dropdown 1 <span>&#10094;</span></div>
    <div class="dropdown-content">
      <a href="#">Link 1</a>
      <a href="#">Link 2</a>
      <a href="#">Link 3</a>
    </div>
  </div>
  <div class="dropdown">
  <span>Status</span>
    <div class="dropbtn">Dropdown 2 <span>&#10094;</span></div>
    <div class="dropdown-content">
      <a href="#">Link 4</a>
      <a href="#">Link 5</a>
      <a href="#">Link 6</a>
    </div>
  </div>
</div>

关于html - 水平创建下拉按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50339008/

10-12 13:33