Recently, I utilized a bootstrap card to display an image with text below it. I opted for the card class because of its solid structure and to avoid excessive CSS styling to horizontally align div lists. I envisioned creating an image gallery with a horizontal scroll, similar to this example: https://i.sstatic.net/YPbsj.jpg
However, I encountered an issue where the cards shrink as I add more of them. What could be causing this problem? Should I avoid using card-group? Perhaps, I need to abandon Bootstrap altogether and develop my own custom solution?
.card-group {
overflow-x: scroll;
white-space: nowrap;
max-width: 30rem;
padding: 1rem;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin="anonymous"></script>
<script src="./index.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin="anonymous">
</head>
<body>
<div class="container mt-4">
<div class="horzontal-scrollgallery">
<div class="card-group">
<div class="card pr-3">
<img class="card-img-top" src="./images/chicago.jpg" alt="Card image">
<div class="card-body text-center">
<h4 class="card-title">John Doe</h4>
</div>
</div>
<div class="card pr-3">
<img class="card-img-top" src="./images/chicago.jpg" alt="Card image">
<div class="card-body text-center">
<h4 class="card-title">John Doe</h4>
</div>
</div>
<div class="card pr-3">
<img class="card-img-top" src="./images/chicago.jpg" alt="Card image">
<div class="card-body text-center">
<h4 class="card-title">John Doe</h4>
</div>
</div>
<div class="card pr-3">
<img class="card-img-top" src="./images/chicago.jpg" alt="Card image">
<div class="card-body text-center">
<h4 class="card-title">>John Doe</h4>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
</body>
</html>