Reputation: 1289
I am trying to apply a border to only the left and right sides of a div with a solid color. When I look at the page, the elements within (which are set to fill the div width) shift over the proper number of pixels, but the border itself (a solid color) appears to not exist, or the border itself is transparent. How I get the solid color border to actually appear? Here is the CSS segment:
#menu {
border-left: 10px solid #490707;
border-right: 10px solid #490707;
}
Upvotes: 1
Views: 284
Reputation: 59819
The border isn't appearing because #menu
height has "collapsed" due to having floated descendants (the list-items) .. you can establish a new block formatting context for #menu
's descendants by adding overflow: hidden;
so that the floats are respected.
Eventually, when the CSS Intrinsic & Extrinsic Sizing Module Level 3 is adopted by browsers, you'll be able to use the contain-floats
value for the min-height
and min-width
properties so you don't have to use overflow: hidden;
anymore.
Equivalent to ‘min-content’ except that when applied to the extent of a block box it forces the inner extent to be large enough to contain the margin boxes of any floats that originate inside the block and that participate in the same block formatting context as the block's immediate contents.
Upvotes: 1