197
rated 0 times
[
199]
[
2]
/ answers: 1 / hits: 79315
/ 11 Years ago, sat, may 11, 2013, 12:00:00
I am working on a small html page. I am using javascript to get the dimensions of the screen. I need to pass that variable to a css style like below. How can I do this? Also I notice that I need to put the px at the end of the value, like top: 100px not top:100. How can I add that to my variable as well? Thanks for any help
<script type=text/javascript>
var percent =1;
var myWidth = Math.round( screen.width * percent);
var myHeight = Math.round( screen.height * percent);
</script>
<style type=text/css>
div.content {
margin: auto;
top: myHeight ;
width: myWidth ;
}
</style>
More From » html