Centralize cards on mobile device

Asked

Viewed 60 times

0

I’m not getting these cards stay centered when on the mobile device, I’ve been told to use media queries, but in that sense I would have to create a new class to assign the css code, I mean, I wouldn’t be taking advantage of what the bootstrap offers. There is some class name that enables me to accomplish this kind of thing.

Follows the code:

<head>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>

<body>
<div class="container">

				<div class="row">

					<div class="col-sm-12 col-md-6 col-lg-4">
						<!--first card-->
						<div class="card mb-5 curadoria-card" style="width: 18rem;">

							<img src="img/festcasa/people-01.jpg" class="card-img-top" alt="...">

							<div class="card-body text-center">

								<h5 class="card-title"><strong style="color: #08979b; font-weight: bold">Nome da pessoa</strong><br/></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">Currículo em anexo</a>

							</div>

						</div>

					</div>
					<div class="col-sm-12 col-md-6 col-lg-4">
						<!--secondary card -->
						<div class="card mb-5" style="width: 18rem;">

							<img src="img/festcasa/people-02.png" class="card-img-top" alt="...">

							<div class="card-body text-center">

								<h5 class="card-title"><strong style="color: #08979b; font-weight: bold">Nome da pessoa</strong><br/></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">Currículo em anexo</a>

							</div>

						</div>

					</div>

					<div class="col-sm-12 col-md-6 col-lg-4">
						<!--third card-->
						<div class="card mb-5" style="width: 18rem;">

							<img src="img/festcasa/people-03.png" class="card-img-top" alt="...">

							<div class="card-body text-center">

								<h5 class="card-title"><strong style="color: #08979b; font-weight: bold">Nome da pessoa</strong><br/></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">Currículo em anexo</a>

							</div>

						</div>
					</div>

				</div>

			</div>
      <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>

Note that they are responsive but not centralized!

1 answer

2


Use the native class .mx-auto in cards:

Information about spacing classes can be found on official documentation, in Portuguese.

<head>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>

<body>
<div class="container">

				<div class="row">

					<div class="col-sm-12 col-md-6 col-lg-4">
						<!--first card-->
						<div class="card mb-5 curadoria-card mx-auto" style="width: 18rem;">

							<img src="img/festcasa/people-01.jpg" class="card-img-top" alt="...">

							<div class="card-body text-center">

								<h5 class="card-title"><strong style="color: #08979b; font-weight: bold">Nome da pessoa</strong><br/></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">Currículo em anexo</a>

							</div>

						</div>

					</div>
					<div class="col-sm-12 col-md-6 col-lg-4">
						<!--secondary card -->
						<div class="card mb-5 mx-auto" style="width: 18rem;">

							<img src="img/festcasa/people-02.png" class="card-img-top" alt="...">

							<div class="card-body text-center">

								<h5 class="card-title"><strong style="color: #08979b; font-weight: bold">Nome da pessoa</strong><br/></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">Currículo em anexo</a>

							</div>

						</div>

					</div>

					<div class="col-sm-12 col-md-6 col-lg-4">
						<!--third card-->
						<div class="card mb-5 mx-auto" style="width: 18rem;">

							<img src="img/festcasa/people-03.png" class="card-img-top" alt="...">

							<div class="card-body text-center">

								<h5 class="card-title"><strong style="color: #08979b; font-weight: bold">Nome da pessoa</strong><br/></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">Currículo em anexo</a>

							</div>

						</div>
					</div>

				</div>

			</div>
      <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>

  • That’s exactly what I needed, I’m already reading the doc, but sometimes I read by demand, which exactly I will use. I will read what you sent me!

  • 1

    Really don’t need to read the whole doc. It serves more for reference when you need it. Good luck!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.