在网上无意中发现个好东西,用css3的data-attribute属性开发按钮,当鼠标经过显示按钮的详细信息。而且实现过程很简单,几行代码就搞定。如下图:
css部分:<style type=”text/css”>
*{margin:0px;padding:0px;}
button
{
background: #db701f;
border: solid 7px #000;
padding: 20px;
box-shadow: inset 0 0 6px #824212;
text-transform: uppercase;
font-weight: bold;
font-family: “Tahoma” , sans-serif;
text-shadow: 1px 1px 3px #824212;
color: #fff;
position: relative;
width: 300px;
font-size:16px;
}
button:hover
{
background: green;
}
button:hover:before
{
/* ——- THIS IS THE MAGIC —————-*/
content: attr(data-hover); /* ——————————————*/
display: block;
background: #000;
position: absolute;
top: 100%;
left: -7px;
right: -7px;
padding: 15px;
}
button:hover:after
{
content: “”;
position: absolute;
display: block;
width: 0;
height: 0;
border: solid 10px transparent;
border-bottom-color: #000;
bottom: 0;
left: 50%;
margin-left: -10px;
z-index: 2;
}
.note
{
margin-top: 100px;
display: block;
}
</style>
html部分代码:
<button data-hover=”test测试”>
css3 data-attribute属性打造漂亮的按钮
</button>