У меня есть код ниже. Я хочу, чтобы второй div
, синий, имел такую же ширину, что и красный div
, а синий div
текст должен быть выровнен по центру как по вертикали, так и по горизонтали.
Я не могу использовать flexbox или grid, потому что нужна поддержка старого браузера.
.red, .blue {
color: white;
}
.red {
background-color: red;
}
.blue {
background-color: blue;
}
.row{
overflow: auto;
}
.row::after {
content: "";
clear: both;
display: table;
}
[class^="col-"] {
float: left;
}
.col-3 {
width: 30%;
}
.col-7 {
width: 70%;
}
<div class="row">
<h1> Example 1</h1>
<div class="col-3 red">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Why do we use it?
</div>
<div class="col-7 blue">ipsum ipsum</div>
</div>