我目前正在尝试创建一个弹出对话框,该对话框应指向触发其外观的元素。当用户点击第一个按钮时,箭头应该指向按钮的中间,以此类推。动态改变指向箭头指向点击源
我知道如何用css创建指向箭头,但问题是如何动态定位它以指向触发其外观的按钮。
请检查此的jsfiddle HERE
/* ========== CSS ========== */
.container {
background:white;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
width:100%;
height:150px;
display: block;
position: relative;
margin-top:20px;
}
#pointer {
border-bottom:solid 10px #FFF;
border-left: solid 8px transparent;
border-right: solid 8px transparent;
position:absolute;
width: 0;
height: 0;
top: -10px;
right: 20px;
}
<!-- ============== HTML =============== -->
<div class="btn-group" role="group" aria-label="...">
<button type="button" class="btn btn-default">Left</button>
<button type="button" class="btn btn-default">Middle</button>
<button type="button" class="btn btn-default">Right</button>
</div>
<div class="container">
<div id="pointer"></div>
</div>
你觉得呢?谢谢。