visibility: hidden
과 visible
대신에 .icon span
에 pointer-events:none;
을 사용해도 됨.
<div class="container">
<div class="icon">
<img src="./images/icon-01.png">
<span>
This HTML tutorial contains hundreds of HTML examples.
</span>
</div>
<div class="icon">
<img src="./images/icon-02.png">
<span>
This CSS tutorial contains hundreds of CSS examples.
</span>
</div>
<div class="icon">
<img src="./images/icon-03.png">
<span>
AngularJS extends HTML with new attributes.
</span>
</div>
<div class="icon">
<img src="./images/icon-04.png">
<span>
Node.js is an open source server environment.
</span>
</div>
</div>
/* Google Web Font */
@import url('https://font.googleapis.com/css?family=Raleway&display=swap');
body {
font-family: 'Raleway', 'sans-serif';
color: #222;
line-height: 1.5em;
margin: 0;
font-weight: 300;
}
a {
color: #222;
text-decoration: none;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.icon {
width: 125px;
height: 125px;
margin: 10px;
position: relative;
}
.icon span {
position: absolute;
background-color: #000;
color: #fff;
width: 300px;
top: -80px;
text-align: center;
padding: 10px;
border-radius: 5px;
left: 50%;
transform: translateX(-50%);
opacity: 0;
transition: .5s;
visibility: hidden;
}
.icon span::after {
content: '';
position: absolute;
background-color: #000;
width: 10px;
height: 10px;
transform: rotate(45deg) translateX(-50%);
bottom: -7px;
left: 50%;
}
.icon:hover span {
opacity: 1;
visibility: visible;
}