gpt4 book ai didi

jquery - 带 Bootstrap 选择的输入组插件

转载 作者:行者123 更新时间:2023-11-28 05:28:55 25 4
gpt4 key购买 nike

我尝试将 Label 2bootstrap-select 一起使用,但它看起来与 bootstrap 不同(Label 1) 一个。如何让下面代码中的两个标签看起来一样?

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="author" content="">

<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">

<title>Test</title>

<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" >
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.2/css/bootstrap-select.min.css">
<link href="http://getbootstrap.com/examples/non-responsive/non-responsive.css" rel="stylesheet">

</head>

<body>

<div class="container">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-addon">Labe 1</span>
<input type="text" class="form-control" name="snpid" placeholder="Test">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">GO!</button>
</span>
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->
<div>
<BR/>
<HR>

<div class="container">
<form class="form-inline">
<div class="form-group">
<span class="input-group-addon">Label 2</span>
</div>
<div class="form-group">
<select id="lunch" class="selectpicker" data-live-search="true" title="Please select a lunch ...">
<option>Hot Dog, Fries and a Soda</option>
<option>Burger, Shake and a Smile</option>
<option>Sugar, Spice and all things nice</option>
<option>Baby Back Ribs</option>
<option>A really really long option made to illustrate an issue with the live search in an inline form</option>
</select>
</div>
</form>
<div>

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.2/js/bootstrap-select.min.js"></script>
<script>
$('.selectpicker').selectpicker();
</script>
</body>
</html>

最佳答案

来自 Bootstrap docs :

Extend form controls by adding text or buttons before, after, or on both sides of any text-based <input>. Use .input-group with an .input-group-addon or .input-group-btn to prepend or append elements to a single .form-control.

您需要包装 select.input-group-addon.input-group :

<div class="input-group">
<span class="input-group-addon">Label 2</span>
<select id="lunch" class="selectpicker form-control" data-live-search="true" title="Please select a lunch ...">
<option>Hot Dog, Fries and a Soda</option>
<option>Burger, Shake and a Smile</option>
<option>Sugar, Spice and all things nice</option>
<option>Baby Back Ribs</option>
<option>A really really long option made to illustrate an issue with the live search in an inline form</option>
</select>
</div>

检查一下:

<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<div class="container">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-addon">Labe 1</span>
<input type="text" class="form-control" name="snpid" placeholder="Test">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">GO!</button>
</span>
</div>
</div>
<br>
<hr>
<div class="container">
<form class="form-inline">
<div class="input-group">
<span class="input-group-addon">Label 2</span>
<select id="lunch" class="selectpicker form-control" data-live-search="true" title="Please select a lunch ...">
<option>Hot Dog, Fries and a Soda</option>
<option>Burger, Shake and a Smile</option>
<option>Sugar, Spice and all things nice</option>
<option>Baby Back Ribs</option>
<option>A really really long option made to illustrate an issue with the live search in an inline form</option>
</select>
</div>
</form>
</div>
</div>

关于jquery - 带 Bootstrap 选择的输入组插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38617914/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com