twitter-bootstrap Bootstrap - 列表组项中的输入组按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26162361/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 21:39:28  来源:igfitidea点击:

Bootstrap - Input group button in List group Item

twitter-bootstrap

提问by Jo?o Cunha

Hey I'm kind of a new guy in bootstrap but I was wondering how to do something.

嘿,我是一个新手,但我想知道该怎么做。

I've been trying and searching but I can't seem to do it. Does anyone know how to get these:

我一直在尝试和搜索,但我似乎无法做到。有谁知道如何获得这些:

<div class="input-group">
  <span class="input-group-btn">
    <button class="btn btn-default" type="button">Go!</button>
  </span>
  <input type="text" class="form-control">
</div>

Sorry I can't quite provide an image right now but on the bootstrap website it is hereon Button Addons.

对不起,我不能完全提供图像,但现在引导网站上它是在这里上的按钮进行附加组件。

into a list-group-item? I want a button like that but on a list-group-item.

list-group-item? 我想要一个这样的按钮,但在列表组项目上。

Can anyone help me?

谁能帮我?

回答by Sebsemillia

Just nest the input-groupinto the list-group-item, like this:

只需将 嵌套input-group到 中list-group-item,如下所示:

<ul class="list-group">
  <li class="list-group-item">
     <div class="input-group">
        <span class="input-group-btn">
            <button class="btn btn-default" type="button">Go!</button>
        </span>
        <input type="text" class="form-control">
    </div><!-- /input-group -->
  </li>
</ul>

If you don't want to have the additional padding, you could do something like this:

如果你不想有额外的填充,你可以做这样的事情:

1.) Add a special class to the .list-group-item:

1.) 添加一个特殊的类.list-group-item

<li class="list-group-item group-btn">
    <div class="input-group">
        <span class="input-group-btn">
            <button class="btn btn-default" type="button">Go!</button>
        </span>
        <input type="text" class="form-control">
    </div><!-- /input-group -->
  </li>

2.) Give it the following CSS:

2.) 给它以下 CSS:

li.group-btn {
  padding: 0;
}

Working Example(1. li is the basic example, the 2. li is without padding)

工作示例(1. li 是基本示例,2. li 没有填充)