Quantcast
Channel: Syntax: Use variable for css value - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by Arjan for Syntax: Use variable for css value

var textH = $(".Text").height();var vertAlign = ((140 - textH)/2);$(".Text").css({ margin-top: vertAlign +'px' });You need to specify the unit, otherwise your browser won't be able to tell whether you...

View Article



Answer by robx for Syntax: Use variable for css value

optionally if you'd like to do more than one style:var styles = {'margin-top':vertAlign,'property':100,'property':somevalue}$(".Text").css(styles);

View Article

Answer by Arman P. for Syntax: Use variable for css value

Remove quotes surrounding vertAlign$(".Text").css('margin-top', vertAlign);Try the above code. It must help you.

View Article

Syntax: Use variable for css value

Trying to keep a box centered vertically within another box. I know there's css that can do this, but I'd rather use jquery, more reliable(?).var textH = $(".Text").height();var vertAlign = ((140 -...

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images