Grow your CSS skills. Land your dream job.

container.style.width = containing element + padding

  • # June 29, 2013 at 12:05 pm

    I have a container that I want resized to whatever the size of screen. I also want it to stay centered. The only way I can figure is to change the container to the size of its containing element plus its padding.

    This is all I’ve got.

    var container = document.getElementById(“container”);
    var $entry = $(‘.entry’);
    container.style.width =

    # June 29, 2013 at 2:08 pm

    I want something like this.

    var new_entry_width = thumbWidth * thumbCols – thumbWidth – 60;

    if(new_entry_width != $(“#container”).width()) {
    var items_width = (windowWidth < thumbWidth * minCols) ? (thumbWidth * minCols) : (thumbWidth * thumbCols);
    if(thumbWidth > 100) {
    $(“#container”).css(“width”, items_width);
    }
    }
    }

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".