注释部分同样可以实现,鼠标移文字上固定位置显示title,不显示默认的title;
html网页主要是用于web站点的制作,对于一个网页用户体验最为重要,如何提升用户体验呢?就要从细节入手。那么html如何给文字链接加上提示呢?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>body {
margin: 0;
padding: 40px;
background: #fff;
font: 80% Arial, Helvetica, sans-serif;
color: #555;
line-height: 180%;
}
p {
clear: both;
margin: 0;
padding: .5em 0;
}/* tooltip */#tooltip {
position: absolute;
border: 1px solid #333;
background: #f7f5d1;
padding: 1px;
color: #333;
display: none;
}</style>
<script src="js/jquery-1.11.3.min.js"></script>
<script>$(function () {// var v;var x=10;var y=20;
$("a.tooltip").mouseover(function (e) {// v=$(this).attr("title");//把class .tooltip中的值取到// $(this).attr("title","");//把原来的titile清空this.myTitle=this.title;this.title="";var tooltip=$("<div id='tooltip'>"+this.myTitle+"</div>");//把class .tooltip中的值传给新元素#tooltiptooltip.appendTo("body");var json={ "top":e.pageY+y+"px", "left":e.pageX+x+"px"};
$("#tooltip").css(json).show("fast");
}).mouseout(function () {
$("#tooltip").remove();//把元素删除,不能用hide();// $(this).attr("title",v);//把原来的属性值添加回来this.title=this.myTitle;
});
})</script>
</head>
</head>
<body>
<p><a href="#" class="tooltip" title="这是我的超链接提示1.">提示1.</a></p>
<p><a href="#" class="tooltip" title="这是我的超链接提示2.">提示2.</a></p>
<p><a href="#" title="这是自带提示1.">自带提示1.</a></p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/xiazai/code/10982">
<img src="https://img.php.cn/upload/webcode/000/000/004/176455800251815.jpg" alt="MVM mall 网上购物系统">
</a>
<div class="aritcle_card_info">
<a href="/xiazai/code/10982">MVM mall 网上购物系统</a>
<p>采用 php+mysql 数据库方式运行的强大网上商店系统,执行效率高速度快,支持多语言,模板和代码分离,轻松创建属于自己的个性化用户界面 v3.5更新: 1).进一步静态化了活动商品. 2).提供了一些重要UFT-8转换文件 3).修复了除了网银在线支付其它支付显示错误的问题. 4).修改了LOGO广告管理,增加LOGO链接后主页LOGO路径错误的问题 5).修改了公告无法发布的问题,可能是打压</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="MVM mall 网上购物系统">
<span>0</span>
</div>
</div>
<a href="/xiazai/code/10982" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="MVM mall 网上购物系统">
</a>
</div>
<p><a href="#" title="这是自带提示2.">自带提示2.</a></p>
</body>
</html>
以上就是关于文字提示的实例代码的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号