Grow your CSS skills. Land your dream job.

how to force sidebar background to fill container element

  • # March 31, 2013 at 5:06 pm

    I’m trying to clone my static HTML/CSS site into a wordpress-themed site, and need help with a sidebar element. The main layout is a content area with left and right sidebars.

    The left sidebar will be a vertical menu with a transparent background. I would like to combine the content area and the right sidebar area, visually, into one common background.

    I have styled the content area and the sidebar to share the same background color, with zero margins so there is no seam between the two.

    The problem is that the sidebar background does not extend to the same length as the content area, so the illusion of the two elements sharing one background is lost.

    The two elements share a parent container element, and I am wondering if there is a CSS rule that might force the sidebar background to fill that parent as does the content element.

    Sorry if this is convoluted, and thanks for any help or pointers!

    # March 31, 2013 at 5:25 pm

    Do you have a link or could you make a Codepen reduced case?

    # March 31, 2013 at 6:31 pm

    Unfortunately I’ve got this running on a localhost so don’t have a link. I could put the HTML in Codepen, but there’s a ton of CSS, and I’m not sure how I would show all of the pertinent code.

    Asked another way, if I had three Div’s in a container as columns, left, center and right, is there a way to force the background of the right Div to fill the height of the main container, which is dictated by the content of the center Div?

    # April 1, 2013 at 10:28 am

    Here is the easiest way you will ever find. Change no html. Just add a couple lines of css http://www.websitecodetutorials.com/code/css/css3-faux-columns.php

    # April 1, 2013 at 6:02 pm

    Thanks, it looks like mine is an old problem: equal height columns. These are some good leads, and I’m sure they’ll provide a solution.

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

You must be logged in to reply to this topic.

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