Expand a DIV width beyond its parent

I had an issue where a content management system restricted the layout of the page to have three columns. I wanted the results of a search, which were displayed in a div tag, to expand to fill (almost) the entire width of the screen. After just a bit of tweaking with padding and width, I ended with this:

<div id=”results” style=”margin-left: calc(-50vw + 50%);padding-left: 15px; width: 98vw; “></div>

Note that your mileage may vary. This particular code worked with the arrangements of elements in my page, and I have not tested it thoroughly enough to say it would work in all instances.

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: