Tuesday, 15 January 2013

Javascript - How to alter a property of a css class -



What am I trying to do here:

I have an every time I The size of the window changes, then the special div can be changed, the Div's class properties are in an external CSS document with the class name '.nav'.

In HTML: & lt; Body onResize = "nav_resize ()" & gt;

In JS:

  var w = window.innerWidth, h = window.innerHeight; Var nav = document.getElementsByClassName ('nav'); Function nav_resize () {if (w> 700) {nav.style.width = w-150}}  

< Div class = "snippet" data-lang = "js" data-hide = "wrong">

  .nav {background color: # 5F1C1C; Status: fixed; Swim left; Width: 190px; Minimum-width: 85px; Top: 105px; Height: 100vh; Hidden flurry; Z-index: 1; }  
I know I'm doing something wrong because nothing happens while trying in the browser.
Any help appreciated.

To control the occurrence of such size changes

  @Media only CSS and CSS style for {// CSS + 700px} {// CSS + style for media only} screen and (max-width: 700 pix) {// CSS-700px} for media only screen and / (minimum-width: 700px) > 

This will avoid problems with the size of the smallest and the opposite


No comments:

Post a Comment