Draw lines with CSS over an image - responsive behaviour -


i want draw lines on image using css3, preferably html5 canvas. have found tutorial , demo uses html div:

http://www.monkeyandcrow.com/samples/css_lines/

however, when try effect on image, line positioned outside of image.

how can line drawn directly on top of image?

also need line width responsive, i.e., if re-scale browser window, image re-scaled (this have been able using javascript, resizing image dinamically), , need pixel width of image re-scale well.

should give , use canvas html5 instead? browser compatibility?

the complete code here:

<!doctype html> <html lang="es">  <head>     <meta charset="utf-8">     <title>lines css</title>     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>     <style>         div.line{             -webkit-transform-origin: 0 50%;                -moz-transform-origin: 0 50%;                     transform-origin: 0 50%;              height: 5px; /* line width of 3 */             background: #948c79; /* black fill */             opacity: 0.5;             box-shadow: 0 0 8px #b99b7e;              /* nice animation on rotates: */             -webkit-transition: -webkit-transform 1s;                -moz-transition:    -moz-transform 1s;                     transition:         transform 1s;           }            div.line:hover{             background: #c30;             box-shadow: 0 0 8px #c30;             opacity: 1;           }            div.line.active{             background: #666;             box-shadow: 0 0 8px #666;             opacity: 1;           }     </style>     <script>         function createline(x1,y1, x2,y2){             var length = math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));             var angle  = math.atan2(y2 - y1, x2 - x1) * 180 / math.pi;             var transform = 'rotate('+angle+'deg)';             var line = $('<div>')             .appendto('#page')             .addclass('line')             .css({               'position': 'relative',               'transform': transform                 })                 .width(length)                 .offset({left: x1, top: y1});              return line;             } // function                 </script> </head> <body>     <p>lines css</p>      <input type="button" value="draw line" onclick="createline(0,0,20,20);" />     <div id="page" style="height:auto;"><p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/man_o%27war_cove_near_lulworth_dorset_arp.jpg/300px-man_o%27war_cove_near_lulworth_dorset_arp.jpg" class="fotografia" /></p></div> </body> 

the jsfiddle is: https://jsfiddle.net/30xh1xpm/ ( notice doesn't draw line ).

i able solve of issues, ie8 behaviour, js library corrected it.

however, strange behaviour of firefox, in webpage example @ beginning, oblied me throught php + gd, compatible 100% of modern browsers. seems css3 worst nightmare of century serious developer.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -