How to get own attributes object into itself
there!
I wanna center the div by horizontal. Now I have to use Javascript + CSS. It looks like this
CSS:
div#block {
left: 50%;
}
JavaScript:
$('#block').css('margin-left', ($('#block').outerWidth()/2) + 'px');
Brobably, I can do like this:
div#block {
left: 50%;
margin-left: self -50%;
}
Thank a lot for you开发者_JAVA百科r help =)
<div id="blockparent"><div id="block"></div></div>
div#blockparent {
width: 100%; /*or fixed width*/
}
div#block {
margin: 0 auto;
}
精彩评论