gpt4 book ai didi

javascript - 工具提示位置外观问题

转载 作者:太空宇宙 更新时间:2023-11-04 01:12:07 24 4
gpt4 key购买 nike

我在这里使用了 Bootstrap....我的弹出窗口提示位置不正确。因为我希望它与 Glyphicon 一起出现在最右 Angular ,但它仍然出现在左侧位置。

所以,我之前尝试过的:

1) 我刚刚更改了 CSS 并尝试将弹出框右对齐,但没有成功。

	$("[data-toggle=popover]").popover({
html: "true",
container: 'body',
title : 'Contact Us <a href="#" class="close" data-dismiss="alert">&times;</a>',
content: function() {
return $('#popover-content').html();
}
});
$(document).on("click", ".popover .close" , function(){
$(this).parents(".popover").popover('hide');
});
	.form-control {width:120px;}
.popover {
max-width:300px; }
#contact_query.btn.btn-primary
{
background-color:#74a5d0;

}
#call_icon.glyphicon.glyphicon-earphone {

position: fixed;
top: 8px;
right: 16px;
font-size: 30px;

}


@media (max-width: 767px) {
#contact_query.btn.btn-primary
{
font-size:13px;


}

#query-pos
{
font-size:13px;

}
#email-pos
{
font-size:13px;

}
#ph_1,#ph_2
{
font-size:13px;
}

}
<!DOCTYPE html>
<html>
<head>
<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.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body>
<div class="container">
<ul class="list-unstyled">
<li><a data-placement="right" data-toggle="popover" data-title="" data-container="body" type="button" data-html="true" href="#contact" id="login_try"><span id="call_icon" class="glyphicon glyphicon-earphone"></span></a></li>

<div id="popover-content" class="hide">

<form class="form-inline" role="form">
<div class="form-group">
<div class="row">
<div class="col-xs-12" ><div>123123121231 &nbsp;&nbsp;<a id="ph_1" href="tel:+9112313313123" type="submit" class="btn btn-primary" ><span class="glyphicon glyphicon-earphone"></span></a></div><br/></div>
<div class="col-xs-12" ><div>1231231223 &nbsp;&nbsp;<a id="ph_2" href="tel:+91121312312" type="submit" class="btn btn-primary" ><span class="glyphicon glyphicon-earphone"></span></a></div></div>
</div><hr>
<div class="row">
<div class="col-xs-12"><p><b>Unable to Contact us? </b><br/>
<p id="query-pos"><a id="contact_query" href="#" class="btn btn-primary">Send your Query</a> and our team will get back to you at the earliest.</p></p></div></div>
<div ><hr><p><b>Or you can</b><br/><p id="email-pos">E-mail us @ <a href="mailto:example@example.com?Subject=Help%20Client">example@example.com</a></p></p></div>

</div>
</form>

</div>
</ul>
</div>
</body>
</html>

最佳答案

在打开弹出窗口而不是图标的 anchor 上添加 position: fixed。因为 popover 正在尝试将 popover 相对于打开它的 anchor 对齐。并且 anchor 的位置仍然在左边,因为它不是 position: fixed 在右边。

.phone_icon {
position: fixed;
top: 8px;
right: 16px;
}

#call_icon.glyphicon.glyphicon-earphone {
font-size: 30px;
}

还将数据位置更改为左侧,因为右侧没有空间。

$("[data-toggle=popover]").popover({
html: "true",
container: 'body',
title: 'Contact Us <a href="#" class="close" data-dismiss="alert">&times;</a>',
content: function() {
return $('#popover-content').html();
}
});
$(document).on("click", ".popover .close", function() {
$(this).parents(".popover").popover('hide');
});
.form-control {
width: 120px;
}

.popover {
max-width: 300px;
}

#contact_query.btn.btn-primary {
background-color: #74a5d0;
}

.phone_icon {
position: fixed;
top: 8px;
right: 16px;
}

#call_icon.glyphicon.glyphicon-earphone {
font-size: 30px;
}

@media (max-width: 767px) {
#contact_query.btn.btn-primary {
font-size: 13px;
}
#query-pos {
font-size: 13px;
}
#email-pos {
font-size: 13px;
}
#ph_1,
#ph_2 {
font-size: 13px;
}
}
<!DOCTYPE html>
<html>

<head>
<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.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<body>
<div class="container">
<ul class="list-unstyled">
<li><a class="phone_icon" data-placement="left" data-toggle="popover" data-title="" data-container="body" type="button" data-html="true" href="#contact" id="login_try"><span id="call_icon" class="glyphicon glyphicon-earphone"></span></a></li>

<div id="popover-content" class="hide">

<form class="form-inline" role="form">
<div class="form-group">
<div class="row">
<div class="col-xs-12">
<div>123123121231 &nbsp;&nbsp;<a id="ph_1" href="tel:+9112313313123" type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-earphone"></span></a></div><br/></div>
<div class="col-xs-12">
<div>1231231223 &nbsp;&nbsp;<a id="ph_2" href="tel:+91121312312" type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-earphone"></span></a></div>
</div>
</div>
<hr>
<div class="row">
<div class="col-xs-12">
<p><b>Unable to Contact us? </b><br/>
<p id="query-pos"><a id="contact_query" href="#" class="btn btn-primary">Send your Query</a> and our team will get back to you at the earliest.</p>
</p>
</div>
</div>
<div>
<hr>
<p><b>Or you can</b><br/>
<p id="email-pos">E-mail us @ <a href="mailto:example@example.com?Subject=Help%20Client">example@example.com</a></p>
</p>
</div>

</div>
</form>

</div>
</ul>
</div>
</body>

</html>

关于javascript - 工具提示位置外观问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50999771/

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