三种实用的HTML锚点实现方式
最编程
2024-08-02 14:49:31
...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<
head
>
<
style
type
=
"text/css"
mce_bogus
=
"1"
>
p.test {
width: 400px;
margin: 5px auto;
border: 1px solid #ccc;
}
p.test strong {
font-size: 16px;
background: #fff;
border-bottom: 1px solid #aaa;
margin: 0;
display: block;
padding: 5px 0;
text-decoration: underline;
color: #059B9A;
cursor: pointer;
}
p.test p {
height: 400px;
background: #f1f1f1;
margin: 0;
}
</
style
>
<
script
type
=
"text/javascript"
>
function intval(v){
v = parseInt(v);
return isNaN(v) ? 0 : v;
} // ?取元素信息
function getPos(e){
var l = 0;
var t = 0;
var w = intval(e.style.width);
var h = intval(e.style.height);