gpt4 book ai didi

css - Bootstrap CSS 将警报对齐到输入字段

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

我正在尝试让我的警报对齐以在我的输入字段旁边弹出。

 <div class="container">
<input type="text" id="barcode" autocomplete="off"/><div id = "alert_placeholder"></div>
</div>

我通过 ajax 调用来调用警报。

function bulkConfirm(text) {
var response = '';
$.ajax({ type: "GET",
url: ("https://"+environment+"/nb/"+user+"/confirm/"+text),
headers: { 'Authorization': authorization},
async: true,
success : function(data)
{
$('#alert_placeholder').html("<div class='alert alert-success alert-dismissable fade in'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a><span class='glyphicon glyphicon-ok' aria-hidden='true' style='padding-right:5px;'></span><strong>'Success!'</strong>"+data+"</div>");
skipUpdate = 1;
updateScans();
}
});
}

最佳答案

为了解决您的问题,您可以将alert 类的padding-left 设置为0:

.alert {
padding-left: 0px !important;
}

如果您想将 alert_placeholder 对齐到输入框的右侧,您可以使用以下样式:

.alert {
padding: 5px !important;
}
#alert_placeholder {
display: inline-block;
}

例子:

//
// simulation of ajax call....
//
var data = ".....";
$('#alert_placeholder').html("<div class='alert alert-success alert-dismissable fade in'>" +
"<a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a>" +
"<span class='glyphicon glyphicon-ok' aria-hidden='true' style='padding-right:5px;'>" +
"</span><strong>'Success!'</strong>"+data+"</div>");


$('#alert_placeholder1').html("<div class='alert1 alert alert-success alert-dismissable fade in'>" +
"<a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a>" +
"<span class='glyphicon glyphicon-ok' aria-hidden='true' style='padding-right:5px;'>" +
"</span><strong>'Success!'</strong>"+data+"</div>");
.alert {
padding-left: 0px !important;
}


.alert1 {
padding: 5px !important;
}
#alert_placeholder1 {
display: inline-block;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>


<div class="container">
<input type="text" id="barcode" autocomplete="off"/><div id="alert_placeholder"></div>
</div>

<div class="container">
<input type="text" id="barcode" autocomplete="off"/><div id="alert_placeholder1"></div>
</div>

关于css - Bootstrap CSS 将警报对齐到输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43522832/

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