html按钮tooltip无法显示,How do you render tooltip on disabled HTML Button

这篇博客分享了一个CSS实现的在多种浏览器下可靠的禁用按钮效果,尽管不完美,但适用于Chrome、Firefox等,避开IE的困扰。重点在于利用CSS hover伪类和`attr()`函数来模拟鼠标悬停时显示提示文字的技巧。
摘要由CSDN通过智能技术生成

An ideal solution would be cross-browser compatible, and this suggestion isn't; I've tested it only on Ubuntu 9.10, though with Chrome, Firefox, Epiphany and Opera and it seems to work reliably in those, which implies reliability in their Windows counterparts. Obviously IE is an entirely different kettle of fish.

That being said:

This idea's based on the following (x)html:

disabled button

And uses the following CSS to achieve something close to your aim:

button {

position: relative;

}

button:hover:after {

position: absolute;

top: 0;

left: 75%;

width: 100%;

content: attr(title);

background-color: #ffa;

color: #000;

line-height: 1.4em;

border: 1px solid #000;

}

button {

position: relative;

box-sizing: border-box;

}

button:hover:after {

position: absolute;

top: 0;

left: 75%;

width: 100%;

content: attr(title);

background-color: #ffa;

color: #000;

line-height: 1.4em;

border: 1px solid #000;

box-shadow: 2px 2px 10px #999;

}

disabled button

It's not ideal, but it was the best non-JavaScript idea I could come up with.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值