简体   繁体   中英

make negative margin-left increase as window is scaled down

How can I make a margin-left:0vw of mydiv-2 go into a negative margin-left and increasingly more negative margin-left as the browser window is scaled further and further down horizontally.

 #mydiv-1{ background-color:orange; width:60%; height:400px; margin-left: 150px } #mydiv-2{ background-color:blue; margin-left:0vw; width:30%; height:150px; }
 <div id="mydiv-1"> <div id="mydiv-2"> </div> </div>

You will just need to do:

#mydiv-2{
  background-color:blue;
  margin-left: -2vw;
  width:30%;
  height:150px;
  }

When the window will decrease, that vw will decrease with it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM