开发者

Javascript alternative height, width control

is there away to use a different positioning system for elements. where you don't change the width and height of the 开发者_如何学Celement instead you can change it using left,right, top, bottom

more or less like the flex controllers?


Yes you can, I'm not 100% sure if it's fully supported in all browsers but you can use absolute positioning and specify ALL of the coordinates.

i.e.

.pos {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

Which should stretch across the whole window.

You can then modify, or animate each of the properties in jQuery..

i.e.

$(".pos").animate({
    bottom: "50%",
    right: "50%"
}, 2000);

Cheers,

Marko

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜