4

Есть 2 блока в одном. Они должны быть: 1) Располагаться в одной строчке 2) Быть по разные стороныодни блок слева, другой справа

1

4 ответа 4

6

.container {
  display: flex;
  justify-content: space-between;
  background-color: gray;
  padding: 1em;
  box-sizing: border-box;
}

.container div {
  width: 5em;
  height: 2em;
  background-color: blue;
}
<div class="container">
  <div></div>
  <div></div>
</div>

5

Задать float-ы для дочерних блоков. И clear для родителя.

div1 {
  float: left;
}
div2 {
  float: right;
}

main-div:after {
  content:'';
  display:table;
  clear:both;
}

4

.container {
    width: 100%;
}

.container div{
    width: 50px;
    height: 50px;
    background-color: green;
}

.container div:nth-child(1) {
   float:left;
}

.container div:nth-child(2) {
   float:right;
}
<div class="container">
  <div></div>
  <div></div>
</div>

1

.container {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
}

.container div{
width: 50px;
height: 50px;
background-color: green;
}
<div class="container">
  <div></div>
  <div></div>
</div>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.