FroboZ
FroboZ

Reputation: 437

absolute positioning of elements in columns

I'm trying to dynamically position divs next to eachother, taking the previous div's y position and adding the current divs width to make the current divs y position. so B.y = A.y+B.width basicly. My code dosen't do that and I feel that it should :/ Any help with solving this problem is greatly appreciated.

Using css float is not an option in this scenario.

            $(".event2").css({
                "width": $(".event2").width()/4});
                $(".event2").css({
                "position().left": ($(".event1").position().left+$(".event2").width())
            });

            $(".event3").css({
                "width": $(".event3").width()/4});
                $(".event3").css({
                "position().left": ($(".event2").position().left+$(".event3").width())
            });

            $(".event4").css({
                "width": $(".event4").width()/4});
                $(".event4").css({
                "position().left": ($(".event3").position().left+$(".event4").width())
            });

Upvotes: 0

Views: 52

Answers (1)

user2396441
user2396441

Reputation:

css({"position().left": "foo"}) seems to be the usual suspect, should be css({"left": "foo"})

Also, not sure what trying to achieve by:

        $(".event2").css({
            "width": $(".event2").width()/4}); // this seems wrong, you're basically 1/4th-ing to own size
        $(".event2").css({
            "position().left": ($(".event1").position().left+$(".event2").width()) // should've been e1.x + e1.w
        });

Upvotes: 1

Related Questions