问题描述:

I want to retrieve width and height of screen so that i can set a division (body is given here) to exact screen height irrespective of different screens , so is this the correct code for using script in css ??

if no , please help me :

HTML FILE :

<html>

head>

<link rel="stylesheet" type="text/css" href="helocss.css">

</head>

<body bgcolor="orange">

</body>

</html>

here is the css file CSS FILE :

 body{

<script type="text/javascript">

var w=screen.availWidth;

var h=screen.availHeight;

width: w;

height: h;

</script>

}

网友答案:

first u can't use javascript in css it should be in i am using jquery to done this

<html>
    <head>
    <script src="https://code.jquery.com/jquery-2.1.4.min.js"> </script>
    <script>
      var width = $(window).width();
      var height = $(window).height();
      
      $("body").width(width).height(height);
        
     </script>


    </head>
    <body bgcolor="orange">


    </body>
    </html>
相关阅读:
Top