【发布时间】:2014-11-15 00:03:55
【问题描述】:
我是个菜鸟,只花了 3 个小时在谷歌上搜索和尝试,但无法弄清楚。我有这个
<span class="payshiptiptop tooltips">
<a href="#" id="payshiptiptop" rel="tooltip" data-placement="right" data-original-title="<div class='paymentmethods'></div>" data-html="true">
GRATIS Versand
</a>
</span>
但如果它是在移动设备上,它应该放在顶部。 由于 2.1.1 不支持自动权限,我尝试了一些来自 stackoverflow 的代码,例如Is it possible to change the position of Bootstrap popovers based on screen width? 和 Changing the position of Bootstrap popovers based on the popover's X position in relation to window edge? 以及许多其他人。
我想这是要走的路:
<script>
var options = {
placement: function (context, source) {
var position = $(source).position();
if (position.left < 480) {
return "top";
}
return "right";
}
};
$("#payshiptiptop").popover(options);
</script>
如果您能帮助我并告诉我必须在我的 php 文件中发布的内容,我将不胜感激。谢谢!
【问题讨论】:
标签: javascript jquery html twitter-bootstrap