3 つの要素とラッパーで作成されたツールチップがあります。
html:
<div class="tooltip-wrapper" style="position: relative;">
<a href="https://twitter.com/jcubic" title="" rel="Twitter">
<img src="http://images.jcubic.pl/jcubic/profile-twitter.png">
</a>
<div class="tooltip" style="top: -34px; left: -18px; display: block; opacity: 0.9648882429441257;">
<div class="box">Twitter</div>
<div class="arrow" style="border-left-width: 5px; border-right-width: 5px; border-top-width: 5px;"></div>
</div>
</div>
インライン スタイルは、javascript (jQuery プラグイン) によって作成されます。
そしてCSS:
.tooltip {
display: none;
position: absolute;
z-index: 100;
}
.tooltip-wrapper .box {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background: #b72100;
padding: 5px 10px;
display: inline-block;
text-align: center;
}
.tooltip-wrapper .arrow {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #b72100;
margin: auto;
}
1つの要素とCSS疑似要素のみを使用してツールチップを作成することは可能ですか:after for arrow?
<div class="tooltip">Twitter</div>
私のウェブサイト(プロファイル アイコン)でデモを見ることができます。
スタイルとマージ.tooltip
してから作成しようとしましたが、スタイルが機能しません。.box
tooltip:after { content: ''; }
.arrow