定規
(2007/05/07 短くしました)
bookmarklet:
改行付き:
// ruler.js (function(L){ var d=document, i=0,a,b, A='appendChild', B='#000 solid 1px', C='createElement', D='margin:0;padding:0;background:transparent;font-size:10px;border:0;', U='px'; a=d.body[A](d[C]('div')); with(a.style) cssText=D+'height:30px;cursor:move', borderTop=B, width=L+1+U; for(;i<=L;i+=10){ b=a[A](d[C]('div')); with(b.style) cssText=D+'position:absolute', marginLeft=i+U, borderLeft=B, height=(i% 50==0?9:5)+U; if(i% 100==0)b.innerHTML='<br>'+i } DD(a); function DD(a){ var d=document,s=a.style,p,f,x,y,E='addEventListener'; s.cursor='move'; s.position='absolute'; s.zIndex='10'; a[E]('mousedown',function(e){ f=1; p=a; x=e.pageX; y=e.pageY; while(p)x-=p.offsetLeft,y-=p.offsetTop,p=p.offsetParent; e.preventDefault(); },0); d[E]('mousemove',function(e){ if(f)s.left=e.pageX-x+'px',s.top=e.pageY-y+'px' },0); d[E]('mouseup',function(){f=0},0); } })(500)
- -