gpt4 book ai didi

css - Bootstrap 图标 float 到最右边

转载 作者:太空宇宙 更新时间:2023-11-04 09:19:20 25 4
gpt4 key购买 nike

我的图标总是 float 到最右边。

见下图: See image below.它不会粘在输入旁边。

我的代码是:

 <div class="form-horizontal">

<div class="form-group">
@Html.Label("date", htmlAttributes: new { @class = "control-label col-md-2" })

<div class="form-group">
<div class="col-md-10">


<div class="input-group date" id="datetimepicker1">
@Html.EditorFor(model => model.pdate, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.pdate, "", new { @class = "text-danger" })
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>

最佳答案

不知道为什么要在代码中使用嵌套的表单组类

可能是您在输入字段上添加了一些 css,所以请将其删除。

只需从下面的答案中删除此 css 并查看区别:

 #datepk{
max-width: 200px;
}

.input-group-addon{
width: 0%;
}
#datepk{
max-width: 200px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Case</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<style>

</style>
<body>

<div class="container">
<div class='col-sm-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker1'>
<input id="datepk"type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>

</div>




</body>
</html>

关于css - Bootstrap 图标 float 到最右边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41585408/

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