Reputation: 688
Consider these basic and identical Bootstrap 3 and Bootstrap 4 samples. When inside the same row, in Bootstrap 3 divA
seems to take as much vertical space as needed based on its own contents, whereas in Bootstrap 4 divA
spans vertically as tall as divB
is depending on its content.
Is there a way in Bootstrap 3 to make divA
act like in v4+? How can you make two div
s inside the same row have the same (not fixed) height?
I've read about the breakpoint changes in Bootstrap 4+ but I can't find any info on why these work differently.
Am I missing something?
#divA {
background-color: red;
border: 1px solid black;
}
#divB {
border: 1px solid black;
}
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-6" id="divA">
<span>B</span>
</div>
<div class="col-xs-6" id="divB">
<div>B</div>
<div>B</div>
<div>B</div>
<div>B</div>
<div>B</div>
<div>B</div>
<div>B</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
#divA {
background-color: red;
border: 1px solid black;
}
#divB {
border: 1px solid black;
}
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-6" id="divA">
<span>B</span>
</div>
<div class="col-sm-6" id="divB">
<div>B</div>
<div>B</div>
<div>B</div>
<div>B</div>
<div>B</div>
<div>B</div>
<div>B</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
Upvotes: 0
Views: 59
Reputation: 56
Just use flex.
.d-flex {
display: flex;
}
.a {
background: red;
width: 30%;
}
<div class="d-flex">
<div class="a">A</div>
<div class="b">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla soluta corporis, repellat architecto error voluptatibus neque vitae tempora laudantium saepe nostrum sint ipsam dignissimos recusandae magnam illo eveniet veritatis! Unde.
</div>
</div>
Upvotes: 2