Skip to main content

Posts

Showing posts from March, 2016

Dynamically Change an Element Width/Height Using CSS3 ONLY!

Problem: I needed to dynamically change the height/width of a div, but I didn't want to write another few lines of  javaScript. Is there a way I can find a pure css solution? you bet! Solution: Thanks to CSS3, we can now do this easily using the calc() function!         #myDiv {             width: calc(100% - 100px);             height: calc(100% - 100px);             margin: auto;             border: solid 1px #000000;         } More good news:  It works on all browsers :) Onward! References: http://www.w3schools.com/CSSref/func_calc.asp http://stackoverflow.com/questions/1192783/css-how-to-set-div-height-100-minus-npx