【发布时间】:2017-06-16 06:10:50
【问题描述】:
我正在尝试在矩形工具提示 div 的每一侧添加一个居中的箭头/三角形,并且我尝试应用其他问题和演示中的一些代码,但没有一个看起来居中或箭头的阴影与 @987654324 重叠@。箭头应该是带有0 0 20px 0 rgba(0, 0, 0, 0.2); 阴影的白色。
HTML:
<div class="tooltip cal-tooltip">
<div class="tooltip cal-tooltip">
<div class="cal-tooltip-cont">
<div class="cal-tooltip-img four-three-img">
<img src="http://placeholdit.imgix.net/~text?txtsize=75&txt=Event%20Photo&w=600&h=400" />
</div>
<div class="card-info">
<h2>Wrapping related content title</h2>
<h3>Event date</h3>
<h3>Event venue</h3>
</div>
</div>
</div>
CSS:
.tooltip {
position: absolute;
top: 0;
z-index: 1;
background-color: white;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2);
}
.tooltip > div {
padding: 15px;
}
.tooltip > div img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
.cal-tooltip {
width: 20em;
cursor: auto;
}
.cal-tooltip .cal-tooltip-cont {
display: flex;
}
.cal-tooltip .cal-tooltip-cont > div {
flex-basis: 50%;
}
.cal-tooltip .cal-tooltip-cont > div:nth-child(1) {
padding-right: 5px;
}
.cal-tooltip .cal-tooltip-cont > div:nth-child(2) {
padding-left: 5px;
}
.cal-tooltip .cal-tooltip-cont > div h2 {
padding-bottom: 5px;
font-size: 1em;
}
.cal-tooltip .cal-tooltip-cont > div h3 {
font-size: .85em;
}
【问题讨论】:
-
这个问题看起来像很多其他关于箭头形状的问题。你在 Stack Overflow 上看过答案了吗?像这样:stackoverflow.com/questions/5623072/…?
标签: css tooltip css-shapes