【发布时间】:2019-09-25 13:42:40
【问题描述】:
我想在文本下方有一个小三角形,当用户将鼠标悬停在不同的选项卡上时,它会指向上方。这是我正在使用的一些代码。
* {
margin: 0;
padding: 0;
list-style: none;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
margin: 10px;
}
.tab {
width: 100%;
padding: 5px;
background: #fff;
color: #000;
cursor: pointer;
font-weight: bold;
border-bottom: 1px solid black;
position: relative;
}
.tab:hover {
background: #a0a0a0;
}
.tab:hover span {
display: block;
}
.tab_child {
padding: 15px;
background: #fff;
}
.selected {
background: #a0a0a0;
}
.contain * {
float: left;
width: 100px;
}
span.triangle {
background-image: url("http://www.inner.org/torah_and_science/mathematics/images/triangle.gif");
background-repeat: none;
display: none;
height: 14px;
width: 16px;
position: absolute;
top: 25px;
left: 25%;
}
<div class="contain">
<div id="one" class="tab selected">Link1</div>
<div id="two" class="tab">Link2</div>
<div id="three" class="tab">Link3</div>
<div id="four" class="tab">Link4</div>
<div id="five" class="tab">Link5</div>
</div>
【问题讨论】:
-
您的哪一部分有问题?
-
这里是如何制作一个 CSS 三角形:stackoverflow.com/questions/7073484/… - 你可以把它放在你的 tab-div 中并使用三角形的颜色(与 background = invisible 相同,在悬停时更改颜色等)
-
我想这就是我遇到问题的部分,任何时候我在其中添加一个三角形都会搞砸一切。像这样:jsfiddle.net/88Uxw/2
标签: html css css-shapes