Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I have a div inside another div with specific width but I want the child div to have width in percentage with browser screen size not its parent div?

I have a div inside another div with specific width but I want the child div to have width in percentage with browser screen size not in percentage with its parent div, meaning when I set the width of the child div to 50%, I want its size to be 50% of the browser screen not 50% of its parent element, I don't want to remove it from the parent-child its important, any way to achieve this without removing it from being a child ?

P.S- Please no answer in JQuery. Either CSS or Javascript. If it is achievable by css it would be really great, but javascript will also be fine.

like image 376
Rohan Negi Avatar asked May 30 '16 07:05

Rohan Negi


1 Answers

You can use VW (ViewPort Width). Example :

.child {width : 50vw}
like image 168
Rey Musa Avatar answered Oct 06 '22 02:10

Rey Musa