* { margin: 0; padding: 0; transition: .3s; background: url('img/crossword.png'); } .header { margin: 10px auto; width: 960px; height: 400px; border-radius: 5px; background: rgba(0, 0, 0, .8); box-shadow: 0px 2px 3px rgba(0,0,0,.4); } @media only screen and (max-width: 950px){ .header { width: 600px; background: #000; } } @media only screen and (max-width: 610px){ .header { width: 200px; background: #000; } } .container { display: inline; } .first { margin: 10px auto; width: 300px; height: 200px; border-radius: 5px; background: rgba(0, 0, 0, .8); box-shadow: 0px 2px 3px rgba(0,0,0,.4); } .second { margin: 10px auto; width: 300px; height: 200px; border-radius: 5px; background: rgba(0, 0, 0, .8); box-shadow: 0px 2px 3px rgba(0,0,0,.4); } 
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="header"></div> <div class="container"> <div class="first"></div> <div class="second"></div> </div> </body> </html> 

How to put a container inline

  • What do you have in mind? - kizoso
  • Put in line - Vitalik Slobodyanuyk
  • one
    explain normally what you want to achieve? the essence of the question is not clear ... - Air

2 answers 2

Register display: inline-block; items:

 * { margin: 0; padding: 0; transition: .3s; background: url('img/crossword.png'); } .header { margin: 10px auto; width: 960px; height: 400px; border-radius: 5px; background: rgba(0, 0, 0, .8); box-shadow: 0px 2px 3px rgba(0,0,0,.4); } @media only screen and (max-width: 950px){ .header { width: 600px; background: #000; } } @media only screen and (max-width: 610px){ .header { width: 200px; background: #000; } } .container { display: inline-block; text-align: center; } .first { margin: 10px auto; width: 300px; height: 200px; border-radius: 5px; background: rgba(0, 0, 0, .8); box-shadow: 0px 2px 3px rgba(0,0,0,.4); display: inline-block; } .second { margin: 10px auto; width: 300px; height: 200px; border-radius: 5px; background: rgba(0, 0, 0, .8); box-shadow: 0px 2px 3px rgba(0,0,0,.4); display: inline-block; } 
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="header"></div> <div class="container"> <div class="first"></div> <div class="second"></div> </div> </body> </html> 

    If you want 2 blocks to stand in one row easier to register: display: flex;