开发者

Javascript alternative height, width control

开发者 https://www.devze.com 2023-01-08 07:37 出处:网络
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

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

精彩评论

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