网页中我加了一个打印的图片,希望用户鼠标放在图片上的时候能够显示一串说明文字,文字的字体大小能够我自己控制~~看网上写的alt的字体无法控制,需要通过层的方式解决,例如下面的代码~~但是通过层的方式实现如何能保证层的位置始终浮在图的右下角的位置呢?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>自定义Alt</title>
</head>
<body>
<span alt="好孩子^O^">过来</span><br><br>
<span alt="好孩子^O^" altbg="red" altcolor=yellow altborder="yellow">过来</span><br><br>
<span alt="好孩子^O^" altbg="#F7F7F7" altcolor="#999999" altborder="#CCCCCC">过来</span><br><br>
<span alt="好孩子^O^" altbg="green" altcolor=yellow altborder="darkgreen">过来</span><br><br>
<span alt="好孩子^O^" altbg="#000000" altcolor="#FFFFFF" altborder="#000000">过来</span>
<div style="display:none;border:1px solid #000000;background-color:#FFFFCC;font-size:15px;position:absolute;padding:2;" id=altlayer></div>
<script>
document.body.onmousemove=quickalt;
document.body.onmouseover=getalt;
document.body.onmouseout=restorealt;
var tempalt='';
function getalt()
{
if(event.srcElement.alt && (event.srcElement.alt!='' || (event.srcElement.alt=='' && tempalt!='')))
{
altlayer.style.left=event.x;
altlayer.style.top=event.y+20;
altlayer.style.display='';
tempalt=event.srcElement.alt;
tempbg=event.srcElement.altbg;
tempcolor=event.srcElement.altcolor;
tempborder=event.srcElement.altborder;
event.srcElement.alt='';
altlayer.innerText=tempalt;
if (typeof(tempbg)!="undefined"){altlayer.style.background=tempbg}else{altlayer.style.background="#FFFFCC"}
if (typeof(tempcolor)!="undefined"){altlayer.style.color=tempcolor}else{altlayer.style.color=tempcolor="#000000"}
if (typeof(tempborder)!="undefined"){altlayer.style.border='1px solid '+tempborder;}else{altlayer.style.border='1px solid #000000';}
}
}
function quickalt()
{
if(altlayer.style.display=='')
{
altlayer.style.left=event.x;
altlayer.style.top=event.y+10;
}
}
function restorealt()
{
event.srcElement.alt=tempalt;
tempalt='';
altlayer.style.display='none';
}
</script>
</body>
</html>但是上面的这个方法,
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>自定义Alt</title>
</head>
<body>
<span alt="好孩子^O^">过来</span><br><br>
<span alt="好孩子^O^" altbg="red" altcolor=yellow altborder="yellow">过来</span><br><br>
<span alt="好孩子^O^" altbg="#F7F7F7" altcolor="#999999" altborder="#CCCCCC">过来</span><br><br>
<span alt="好孩子^O^" altbg="green" altcolor=yellow altborder="darkgreen">过来</span><br><br>
<span alt="好孩子^O^" altbg="#000000" altcolor="#FFFFFF" altborder="#000000">过来</span>
<div style="display:none;border:1px solid #000000;background-color:#FFFFCC;font-size:15px;position:absolute;padding:2;" id=altlayer></div>
<script>
document.body.onmousemove=quickalt;
document.body.onmouseover=getalt;
document.body.onmouseout=restorealt;
var tempalt='';
function getalt()
{
if(event.srcElement.alt && (event.srcElement.alt!='' || (event.srcElement.alt=='' && tempalt!='')))
{
altlayer.style.left=event.x;
altlayer.style.top=event.y+20;
altlayer.style.display='';
tempalt=event.srcElement.alt;
tempbg=event.srcElement.altbg;
tempcolor=event.srcElement.altcolor;
tempborder=event.srcElement.altborder;
event.srcElement.alt='';
altlayer.innerText=tempalt;
if (typeof(tempbg)!="undefined"){altlayer.style.background=tempbg}else{altlayer.style.background="#FFFFCC"}
if (typeof(tempcolor)!="undefined"){altlayer.style.color=tempcolor}else{altlayer.style.color=tempcolor="#000000"}
if (typeof(tempborder)!="undefined"){altlayer.style.border='1px solid '+tempborder;}else{altlayer.style.border='1px solid #000000';}
}
}
function quickalt()
{
if(altlayer.style.display=='')
{
altlayer.style.left=event.x;
altlayer.style.top=event.y+10;
}
}
function restorealt()
{
event.srcElement.alt=tempalt;
tempalt='';
altlayer.style.display='none';
}
</script>
</body>
</html>但是上面的这个方法,
解决方案 »
- 紧急求助!!ExtJS grid triggerfield的问题
- 如何用js或者juqery制作一个遮罩层,让后让遮罩层有局部挖空效果。
- 讨论 detect ms office version
- 想在iframe中加javascript事件
- 一个页面需要大家帮帮忙,感激不敬!!!
- 谁有javascript查询手册啊?
- Select控件中如何正确的获取选中的option呢?
- 怎样把ASP程序写入到js文件中.然后再通过js调用
- document.write的使用?
- 页面上有许多checkbox框,已赋值,名字相同,如何遍历每个checkbox显示出来每个checkbox的值?
- 为什么添加不了呢?
- 这段Js火狐不支持。。请各位指教
里面有两个例子