https://codepen.io/jonmilner/pen/bfkKF शायद एक उपयोगी उदाहरण है।
<div class="social-icons">
<a class="social-icon social-icon--codepen">
<i class="fa fa-codepen"></i>
<div class="tooltip">Codepen</div>
</div>
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
/* Color Variables */
$color-codepen: #000;
/* Social Icon Mixin */
@mixin social-icon($color) {
background: $color;
background: linear-gradient(tint($color, 5%), shade($color, 5%));
border-bottom: 1px solid shade($color, 20%);
color: tint($color, 50%);
&:hover {
color: tint($color, 80%);
text-shadow: 0px 1px 0px shade($color, 20%);
}
.tooltip {
background: $color;
background: linear-gradient(tint($color, 15%), $color);
color: tint($color, 80%);
&:after {
border-top-color: $color;
}
}
}
/* Social Icons */
.social-icons {
display: flex;
}
.social-icon {
display: flex;
align-items: center;
justify-content: center;
position: relative;
width: 80px;
height: 80px;
margin: 0 0.5rem;
border-radius: 50%;
cursor: pointer;
font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
font-size: 2.5rem;
text-decoration: none;
text-shadow: 0 1px 0 rgba(0,0,0,0.2);
transition: all 0.15s ease;
&:hover {
color: #fff;
.tooltip {
visibility: visible;
opacity: 1;
transform: translate(-50%, -150%);
}
}
&:active {
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.5) inset;
}
&--codepen { @include social-icon($color-codepen); }
i {
position: relative;
top: 1px;
}
}
/* Tooltips */
.tooltip {
display: block;
position: absolute;
top: 0;
left: 50%;
padding: 0.8rem 1rem;
border-radius: 3px;
font-size: 0.8rem;
font-weight: bold;
opacity: 0;
pointer-events: none;
text-transform: uppercase;
transform: translate(-50%, -100%);
transition: all 0.3s ease;
z-index: 1;
&:after {
display: block;
position: absolute;
bottom: 0;
left: 50%;
width: 0;
height: 0;
content: "";
border: solid;
border-width: 10px 10px 0 10px;
border-color: transparent;
transform: translate(-50%, 100%);
}
}
स्रोत
2017-03-08 19:00:05
ठीक है, तो मुझे लगता है कि एक नई सुविधा है जिसके लिए कोड को जेएसफ़ील्ड के साथ सबमिट करने की आवश्यकता है। मुझे बस ऐसा करने में परेशानी हो रही है, यही कारण है कि यह उपरोक्त सभी मजाकिया दिखा रहा है। यदि आप में से कोई भी मूल विचार मूल पोस्ट पर है, तो मैं सलाह की सराहना करता हूं। – Harriet