Evert Heylen
Evert Heylen

Reputation: 1061

Centering a div horizontally inside a container which can change dimensions

I need to center a div ('#expand') in a container. The div may overlap the content in the container, but only the visible part (i.e. no margins left or right from the div overlapping the content) This example seems to work (using another container and margins on auto), but I need it to overlap the border of the container.

Upvotes: 1

Views: 61

Answers (1)

Mister Epic
Mister Epic

Reputation: 16733

I'm unsure about what you're looking for, exactly, but if you're looking to center an element, you would typically do this:

div#expand{margin-left:auto;margin-right:auto;}

Upvotes: 1

Related Questions