2017-02-21 77 views
-1

我有一個由CSS的圓形狀,我試圖把當我徘徊到了中圈出現一個提示,就如何做到這一點的任何想法的工具提示? 這裏是我的圈子代碼:放在CSS形狀

#circle1 { 
 
\t width: 52px; 
 
\t height: 52px; 
 
\t background: #f5e25d; 
 
    opacity: 0.9 
 
\t -moz-border-radius: 50%; 
 
\t -webkit-border-radius: 50px; 
 
\t border-radius: 50px; 
 
}
<div id="circle1"></div>

回答

1

您可以通過將一個HTML元素內部#circle1做到這一點(我用了span)的提示,並採用#circle1:hover顯示工具提示。然後,我把一個三角形作爲span::after僞元素。我用CSS Triangle Generator來創建工具提示三角形。

.wrap { 
 
    overflow: auto; 
 
    padding: 10%; 
 
    width: 100%; 
 
    background: #eee; 
 
    box-sizing: border-box; 
 
} 
 

 
#circle1 { 
 
    display: block; 
 
    width: 52px; 
 
    height: 52px; 
 
    background: #f5e25d; 
 
    opacity: 0.9 -moz-border-radius: 50%; 
 
    -webkit-border-radius: 50%; 
 
    border-radius: 50%; 
 
    margin: 20px auto auto; 
 
    position: relative; 
 
} 
 

 
span.tooltip { 
 
    visibility: hidden; 
 
    position: absolute; 
 
    bottom: calc(100% + 20px); 
 
    left: 50%; 
 
    transform: translateX(-50%); 
 
    width: 200px; 
 
    background: #444; 
 
    color: white; 
 
    padding: 10px; 
 
    box-sizing: border-box; 
 
    border-radius: 4px; 
 
    text-align: center; 
 
    font-family: sans-serif; 
 
} 
 

 
span.tooltip::after { 
 
    content: ''; 
 
    display: block; 
 
    position: absolute; 
 
    top: 100%; 
 
    left: 50%; 
 
    transform: translateX(-50%); 
 
    width: 0; 
 
    height: 0; 
 
    border-style: solid; 
 
    border-width: 10px 5px 0 5px; 
 
    border-color: #444444 transparent transparent transparent; 
 
} 
 

 
#circle1:hover span.tooltip { 
 
    visibility: visible; 
 
}
<div class="wrap"> 
 
    <a id="circle1"> 
 
    <span class="tooltip">Tooltip, baby, yeah!</span> 
 
    </a> 
 
</div>

+0

謝謝你,一個提示的東西,看起來像這樣https://webdesignerhut.com/wp-content/uploads/2015/08/pure-css-tooltips.png 你給我的答案的一半與三角形 – stephjhonny

+0

@stephjhonny更新。 – Jesse

+0

非常感謝你,你是最棒的! – stephjhonny