I have this javascript to center a span in a div:
var winWidth = $(window).width();
var winHeight = $(window).height();
var positionLeft = (winWidth/2) - 62;
var positionTop = (winHeight/2) - 32;
$('#centerMessage').ccs("position","absolute");
$('#centerMessage').ccs("top",positionTop);
$('#centerMessage').ccs("left",positionLeft);
I keep getting the error that the object does not have the method css. Any idea what is wrong?
All the HTML and CSS are at this fiddle (I am getting the exact same error there: http://jsfiddle.net/chromedude/s6WQD/
you are using ccs not css in your code
$('#centerMessage').css("position","absolute");
$('#centerMessage').css("top",positionTop + 'px'); // add unit also
$('#centerMessage').css("left",positionLeft + 'px');
You should add units to your values, as well:
$('#centerMessage').css("top",positionTop + "px");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With