我需要帮助。如何管理超链接的标题,例如如果我有一个像这样的超链接
<a href="#" title="Hello">Press here</a>
我如何更改单词“Hello”的字体和大小?
我需要帮助。如何管理超链接的标题,例如如果我有一个像这样的超链接
<a href="#" title="Hello">Press here</a>
我如何更改单词“Hello”的字体和大小?
您可以使用a[data-title]:hover
来设置样式(而不是使用title
)。
例如:
<a href="#" data-title="Nice CSS title">Test</a>
a {
color: #900;
text-decoration: none;
}
a:hover {
color: red;
position: relative;
}
a[data-title]:hover:after {
content: attr(data-title);
padding: 4px 8px;
color: #333;
position: absolute;
left: 0;
top: 100%;
white-space: nowrap;
z-index: 20px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0px 0px 4px #222;
-webkit-box-shadow: 0px 0px 4px #222;
box-shadow: 0px 0px 4px #222;
background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #eeeeee),color-stop(1, #cccccc));
background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);
background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);
background-image: -o-linear-gradient(top, #eeeeee, #cccccc);
}
content: attr(data-title);
这样标题就不会显示出来。 - dfsqtitle
属性更改为 tip
,浏览器的标题弹出窗口就不会显示。请参见:http://jsfiddle.net/tDQWN/1/ - ijse好的,你无法更改浏览器默认设置。但是你可以使用一个小型的jQuery插件来创建工具提示,并完全控制鼠标悬停时显示元素的外观样式。 点击此链接查看示例
:after
和更改默认标题样式是不同的。 - dfsq嗨,你不能更改标签内Title属性的样式。我的意思是你可以,但是有一些浏览器不兼容。 我认为最好的解决方案是为该标签创建一个特定的类,并在该标签内部放置span。 就像这样:
<a href="#" class="pop">Press here <span>Hello</span></a>
a.pop {
color: blue;
text-decoration: none;
position: relative
}
a.pop:hover {
text-decoration: underline;
}
a.pop span {
display:none;
}
a.pop:hover span {
display: block;
position: absolute;
left:0;
z-index:100;
background: grey;
padding: 5px 10px;
font-size:13px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
text-decoration: none;
}