I have the following code and html (boostrap enabled) page which simply displays three bootstrap cards with images on the page.
I want
a) A margin from the left hand side to be included
b) The cards to display horizontally (across the screen one after the other) rather than vertically.
I have tried various things but to no avail. Could someone with a clear explanation for a beginner explain how to achieve these things.
Full code
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
</head>
<body>
<h1>Website</h1>
<h2>Site with multiple horizontal cards</h2>
<!-- card 1-->
<div class="card" style="width: 14rem;">
<img src="https://cdn5.vectorstock.com/i/1000x1000/23/24/ladybug-insect-small-icon-animal-vector-19752324.jpg" class="card-img-top" alt="...>
<div class="card-body">
<h5 class="card-title">Card 1</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
<!-- card 2-->
<div class="card" style="width: 14rem;">
<img src="https://cdn5.vectorstock.com/i/1000x1000/23/24/ladybug-insect-small-icon-animal-vector-19752324.jpg" class="card-img-top" alt="...>
<div class="card-body">
<h5 class="card-title">Card 1</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
<!-- card 3-->
<div class="card" style="width: 14rem;">
<img src="https://cdn5.vectorstock.com/i/1000x1000/23/24/ladybug-insect-small-icon-animal-vector-19752324.jpg" class="card-img-top" alt="...>
<div class="card-body">
<h5 class="card-title">Card 1</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
</body>
</html>
Trinket
https://trinket.io/html/8fcb4c4f39?runMode=autorun
Current Display
Update:
I have understood that I could start again and try and implement everything inside this structure
<div class="container">
<div class="row">
<div class="col-sm">
One of three columns
</div>
<div class="col-sm">
One of three columns
</div>
<div class="col-sm">
One of three columns
</div>
</div>
But for teaching purposes, is there an easy way to just add to what I have to achieve the result and thereby teach the principles of what is being done.
question from:
https://stackoverflow.com/questions/65598470/bootstrap-how-to-add-a-margin-and-make-these-cards-display-horizontally 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…