You can use media queries. You can set the conditions under which a particular block will take on certain styles. In your example, if the window width is 1100px, then the left block is 250px and the right one is 900 pixels, but it turns out that it will not fit, since 900 + 250 = 1150 pixels and the right block will be on a new line. The main thing is that you understand, you can set in%, as in previous examples, and if you need a specific width, then use media queries
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Document</title> <style> .div-1 { float: left; height: 500px; width: 250px; background-color: black; } .div-2 { /* Π¨ΠΈΡΠΈΠ½Π° ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ */ width: 500px; float: left; height: 500px; background-color: orange; } /* ΠΠΎΠ³Π΄Π° ΡΠΈΡΠΈΠ½Π° ΠΎΠΊΠ½Π° Π΄ΠΎ 900 ΠΏΠΈΠΊΡΠ΅Π»Π΅ΠΉ, ΡΠΈΡΠΈΠ½Π° div-2 Π±ΡΠ΄Π΅Ρ 600px */ @media screen and (max-width: 900px){ .div-2 { width: 600px; } } /* ΠΠΎΠ³Π΄Π° ΡΠΈΡΠΈΠ½Π° ΠΎΠΊΠ½Π° ΠΎΡ 1100 ΠΏΠΈΠΊΡΠ΅Π»Π΅ΠΉ, ΡΠΈΡΠΈΠ½Π° div-2 Π±ΡΠ΄Π΅Ρ 900px */ @media screen and (min-width: 1100px){ .div-2 { width: 900px; } } </style>
<body> <div class="div-1"></div> <div class="div-2"></div> </body>