Ashburn, February 22, 2018

How to make div fill remaining width

More often than not, I encounter myself having 2 divs: one in the left side and one in the right side of my page. The one in the left side has fixed width and I want the one of the right side to fill the remaining width space. Researching and testing I came up with the best solution that works like a charm.

Here I will show you how to make div fill remaining width.

How to make div fill remaining width

Here I provide you 2 pieces of code: html and css. Both seem accomplish the task:

background-size: contain;

left div

By adding a left margin to the #right div same as the #left div width, it’s own contents is forced to shift this amount.

Cheers,

About Karlos Maldonado 41 Articles
Computer Sciences Engineer graduated from Florida Atlantic University (FAU) in Boca Raton, Florida. Has gotten great experience in the IT and Web Development industry working for companies such as SIRIUS XM RADIO, 4MEDIA as well as collaborating with local companies.

Be the first to comment

Leave a Reply

Your email address will not be published.