There are two <div> :

  <div id='const_width' style='width: 1170px;'> <div id='set_length' style='width: 100%;'>Моя мечта - быть растянутым на всю страницу</div> </div> 

How to stretch the set_length div to set_length the entire page width?
It turns out that if the screen is large, then set_length stretched to 1170px . And I need the full width of the screen

How to do this using css + js ?

  • You have it stretched to 100% only the parent unit. - Dmitriy Kondratiuk
  • If only with the help of the script - Yuri
  • The parent unit is 1170px, but the child is already 100% parent (which is 1170px in inline style) and the child doesn’t rattle 100% of the screen unless through positioning + js - user33274
  • Why can't parental block be stretched? - heff

1 answer 1

You only need to change the percentage in CSS :)

 $(function() { var e = $('.two'), p0 = $('.one'), p1 = $('body'); var w = (e.outerWidth() / p0.outerWidth()) * p1.outerWidth(); e.css({width: w}); }); 
 .one {width:300px;height:50px;border:1px solid black} .two {width:100%;height:50px;background-color:red} 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="one"> <div class="two"> </div> </div> 

  • I have never understood why stretch a child? This is not a niggle, but a question for “understanding” - user33274
  • @Geyan, to be honest, I myself do not understand. I never had to do that. Maybe someone has a situation like this) - Yuri
  • I give one hundred percent that just for fun - user33274
  • @Geyan, I don’t know. Once already asked this question. Maybe someone really needs someone - Yuri
  • @Geyan, the only thing was. When you create a one-page with a centered main unit, you need to do one of the categories not inside, but what it would be from edge to edge of the page. Maybe over this - Yuri