So I’m using Chris Coyier’s CSS3 box-sizing grid setup. And I’ve got my grids set up perfect. Inside of each module I have a div which will set the background to be a CSS3 RGBA linear-gradient. All is well and shows up fine, but the since I’m using padding, the background of the last element is taking up the width of the module plus the padding. If you check out the example that might explain it further, the last module is the troubled one. I’ve tried to reset last element to padding-right: 30px which forms the correct width but then it’s not spaced out 100% over the width of the container.
LIVE EXAMPLE So I’m using Chris Coyier’s CSS3 box-sizing grid setup . And I’ve
Share
note this answer has multiple edits to reflect the evolution of the problem and needs
You’re telling the browser each element is 25% of the available width, then you are telling it to deduct 30px from the right of each element to space them out with. Then you are telling it “except for the last one, don’t deduct anything from the right” so the first 3 are really 25%-30px, and the last one is the only one that is truly 25%.
How to resolve this is going to depend on what you want in your final layout, but I would get rid of the bit that says the last item has right-padding of 0px, and set all the elements to have left-padding of 15px and right-padding of 15px.
EDIT1
After clarifying needs, this answer suits OP better: http://jsfiddle.net/Az3eH/
HTML:
CSS:
Edit 2
Upon further inquiry with OP, it appears that specifically what he needs (mixed percentage and fixed widths that would add up to 100% of the available width with variable numbers of columns and sizes) isn’t really possible with a pure HTML/CSS solution. With this in mind, it is my opinion that he go with a fixed layout as per 960.gs which would allow better options in figuring out what width each percent should be. i.e: 100% == 960px and all subdivisions be a fixed width fraction of that.