html css帮助提示,CSS 工具提示

工具提示箭头

如需创建在工具提示的指定侧面显示的箭头,请在工具提示后添加“空的”内容,并使用伪元素类 ::after 和 content 属性。箭头本身是使用边框创建的。这会使工具提示看起来像气泡。

本例演示如何在工具提示的底部添加箭头:

底部箭头

.tooltip .tooltiptext::after {

content: " ";

position: absolute;

top: 100%; /* At the bottom of the tooltip */

left: 50%;

margin-left: -5px;

border-width: 5px;

border-style: solid;

border-color: black transparent transparent transparent;

}

结果:

请把鼠标指针移动到这段文字上方

Tooltip text

例子解释

将箭头定位在工具提示内:top: 100% 将箭头放置在工具提示的底部。left: 50% 将使箭头居中。

注意:border-width 属性指定箭头的大小。如果您更改此设置,也请将 margin-left 值更改为相同值。这将使箭头居中。

border-color 用于将内容转换为箭头。我们将上边框设置为黑色,其余设置为透明。如果所有面都是黑色,则最终将得到一个黑色的方形框。

本例演示了如何在工具提示的顶部添加箭头。请注意,这次我们设置了下边框的颜色:

顶部箭头

.tooltip .tooltiptext::after {

content: " ";

position: absolute;

bottom: 100%; /* At the top of the tooltip */

left: 50%;

margin-left: -5px;

border-width: 5px;

border-style: solid;

border-color: transparent transparent black transparent;

}

结果:

请把鼠标指针移动到这段文字上方

Tooltip text

本例演示如何在工具提示的左侧添加箭头:

左侧箭头

.tooltip .tooltiptext::after {

content: " ";

position: absolute;

top: 50%;

right: 100%; /* To the left of the tooltip */

margin-top: -5px;

border-width: 5px;

border-style: solid;

border-color: transparent black transparent transparent;

}

结果:

请把鼠标指针移动到这段文字上方

Tooltip text

本例演示如何在工具提示的右侧添加箭头:

右侧箭头

.tooltip .tooltiptext::after {

content: " ";

position: absolute;

top: 50%;

left: 100%; /* To the right of the tooltip */

margin-top: -5px;

border-width: 5px;

border-style: solid;

border-color: transparent transparent transparent black;

}

结果:

请把鼠标指针移动到这段文字上方

Tooltip text

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值