Пишем нашу разметку:
Пишем стиль:
Немного придадим динамики:
Смотрим наш результат:
HTML:
<div class="card">
<div class="hint">
<span class="icon-info"></span>
</div>
</div>
CSS:
body {
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: #f5f4f6;
}
.card {
position: relative;
width: 240px;
height: 180px;
border-radius: 12px;
background: #fff;
box-shadow: 0 12px 48px -8px rgba(0,0,0,0.1);
}
.card .hint {
position: absolute;
top: -12px;
right: -12px;
width: 32px;
height: 32px;
background: #000;
border-radius: 16px;
transition: all 0.2s ease;
}
.card .hint .icon-info {
position: absolute;
z-index: 1;
top: 0;
right: 0;
display: block;
width: 32px;
height: 32px;
border-radius: 16px;
cursor: pointer;
pointer-events: auto;
}
.card .hint .icon-info:before,
.card .hint .icon-info:after {
content: '';
position: absolute;
width: 2px;
height: 12px;
background: #fff;
border-radius: 2px;
transform-origin: center center;
transition: all 0.2s ease;
}
.card .hint .icon-info:before {
transform: translate(15px, 6px) rotate(0) scale(1, 0.2);
}
.card .hint .icon-info:after {
transform: translate(15px, 12px) rotate(0) scale(1, 0.5);
}
.card .hint.show {
width: calc(100% + 24px);
height: calc(100% + 24px);
}
.card .hint.show .icon-info:before {
transform: translate(15px, 10px) rotate(-45deg);
}
.card .hint.show .icon-info:after {
transform: translate(15px, 10px) rotate(45deg);
}
JavaScript:
$('.hint').click(function() {
$(this).toggleClass("show");
});