效果:
image.png
代码:
<div class="content-wrapper">
hover me
<div class="hover-detail">
<span>商品1</span>
<span>商品2</span>
<span>商品3</span>
</div>
</div>
.content-wrapper {
position: relative;
height: 32px;
cursor: pointer;
/*float: left;
white-space: nowrap;内容要显示在一行,且浮动时,要加*/
}
.hover-detail {
position: absolute;
top: 30px;
left: 0;
/*width: 116px;*/
/*height: 72px;*/
background-color: #ffffff;
box-shadow: 1px 2px 7px 0px rgba(0, 0, 0, 0.2);
border: solid 1px #ececec;
line-height: 18px;
font-size: 12px;
color: #333333;
padding: 10px;
text-align: left;
cursor: auto;
opacity: 0;
transform: scale(0);
transition: all 0.4s;
}
.hover-detail::before {
content: '';
position: absolute;
top: -5px;
left: 53px;
width: 10px;
height: 10px;
background: #fff;
transform: rotate(-45deg);
box-shadow: 2px -1px 8px 0px rgba(0, 0, 0, 0.17);
}
.hover-detail::after {
content: '';
position: absolute;
top: 0px;
left: 40px;
width: 35px;
height: 9px;
background: #fff;
}
.content-wrapper:hover .hover-detail {
z-index: 10;
opacity: 1;
transform: scale(1);
}
网友评论