javascript - Simple js add for 3d -
im not sure why not working, i've tried many different ways doesnt want work, doing wrong?
im trying add 3d inset parallax effect
my html
<head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>title</title> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="3d.js" type="text/javascript" /> </head> <body> <div class="inset" style="margin:0 auto"> text here </div> <h1>3d inset parallax effect</h1> <p class="inset">the following example of how can create illusion of 3d inset block-level element (with parallax on scroll position) using basic css , jquery. see effect in action, scroll page.</p> <h2>example form:</h2> <form> <label> first name: <input class="inset" type="text" placeholder="enter first name" /> </label> <label> last name: <input class="inset" type="text" placeholder="enter last name" /> </label> </body> </html>
my 3d.js file contains this
var insets = $('.inset'), origborderwidth = parseint(insets.css('border-top-width')), win = $(window); function set3d() { var windowheight = win.height(); insets.each(function() { var self = $(this), scrollheight = win.scrolltop(), elementposition = self.position(), positionpercenttop = math.round((elementposition.top - scrollheight) / windowheight * 100), positionpercentbottom = math.round((elementposition.top + self.outerheight() - scrollheight) / windowheight * 100); self.css({ 'border-top-width' : origborderwidth - (origborderwidth * (positionpercenttop / 100)) + 'px', 'border-bottom-width' : origborderwidth * (positionpercentbottom / 100) + 'px' }); }); }; win.on('load scroll resize', function() { set3d(); });
the issue im having obviosly conecting js code page, ive tried putting between in head, body. doest work.
the css works percetly , appears fine js
you're not referencing script properly. javascript file you're trying include needs in opening , closing <script></script>
tag. here's reference documentation
http://www.w3.org/tr/html4/interact/scripts.html#h-18.2.1
you should put javascript file so, making sure it's within opening , closing <head></head>
tags. code can see is.
<script type="text/javascript" src="3d.js"></script>
Comments
Post a Comment