BOOTSTRAP card does not move

Asked

Viewed 102 times

-1

I am trying to add col-12 to the card below that is in the Discounts section, but it does not work at all, in case I add another card and put both in col-6 only the first card moves the left one is stopped!

<head>
  <title></title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link href="./css/bootstrap.min.css" rel="stylesheet">
  <link href="./css/main.css" rel="stylesheet">

</head>

<body>

  <header>
    <nav class="navbar navbar-expand-md navbar-light  menu ">
      <a class="navbar-brand" href="#"> <img src="./img/other-brand.jpg" /></a>
      <button class="navbar-toggler btn" type="button" data-toggle="collapse" data-target="#conteudoNavbarSuportado"
        aria-controls="conteudoNavbarSuportado" aria-expanded="false" aria-label="Alterna navegação">
        <span class="navbar-toggler-icon"></span>
      </button>


      <div class="collapse navbar-collapse" id="conteudoNavbarSuportado">

        <ul class=" nav navbar ml-auto">
          <li class="nav-item ">
            <a class="nav-link" href="#">UNIDADES</a>
          </li>
          <li class="nav-item  ">
            <a class="nav-link" href="#">ESPAÇO DO ALUNO</a>
          </li>
          <li class="nav-item  ">
            <a class="nav-link" href="#">AGENDE O SEU HORÁRIO</a>
          </li>
        </ul>
      </div>
    </nav>
  </header>





  <section class=" BOX - 1">

    <div class="container-fluid p-0 ">
      <img src="./img/agora vai.jpg" />

    </div>

  </section>




  <section class=" BOX - 2">

    <div class="container part1 ">





      <h1>CONCEITO <span class="changeorange">JGYM</span></h1>

      <p class="sobrep"> Inaugurada em 2020, a JGYM foi criada com o propósito de democratizar o acesso à prática de
        atividade física de alto padrão, <span class="porange"> com planos acessíveis e adesão facilitada. </span> </p>







    </div>



  </section>


  <section class="descontos">
<div class="conteiner">
  <div class="row">
  <div class="col-12">
    <div class="card" style="width: 18rem;">
      <img src="..." class="card-img-top" alt="...">
      <div class="card-body">
        <h5 class="card-title">Card title</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>
      </div>
      <ul class="list-group list-group-flush">
        <li class="list-group-item">Cras justo odio</li>
        <li class="list-group-item">Dapibus ac facilisis in</li>
        <li class="list-group-item">Vestibulum at eros</li>
      </ul>
      <div class="card-body">
        <a href="#" class="card-link">Card link</a>
        <a href="#" class="card-link">Another link</a>
      </div>
    </div>
  </div>
</div> 
</div>


</section>





  <script type="text/javascript" src="./js/jquery-3.5.1.slim.min.js"></script>
  <script type="text/javascript" src="./js/popper.min.js"></script>
  <script type="text/javascript" src="./js/bootstrap.min.js"></script>




















</body>

  • Is there a specific reason for writing your text in high box?

  • was not even noticed, already removed mt obgd

  • Dear your answer is in the documentation... if you want a card next to each other see how it does that has various details and options https://getbootstrap.com/docs/4.4/components/card/ and in this answer has a template that can help you https://en.stackoverflow.com/questions/450349/top-of-picture-no-background/450370#450370

1 answer

0

You have problems with your HTML. You are leaving spaces between class characters <section class=" BOX - 2"> so the style will only be affected in elements that have the class BOX BOX and not BOX - 2. You’re putting the property style and setting width of width <div class="card" style="width: 18rem;"> which limits the width of the card to this specific size, thus losing the grid that the bootstrap has. It is tbm setting the columns on the card <div class="col-12">, when the ideal would be to let bootstrap handle itself leaving just like this class="col" and the problem that was reported in the question is that it just misspelled container in the discounts section.

Example using only 1 card

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">

<header>
  <nav class="navbar navbar-expand-md navbar-light bg-light  menu">
    <a class="navbar-brand" href="#"> <img src="https://getbootstrap.com.br/docs/4.1/assets/img/favicons/favicon-32x32.png" /></a>
    <button class="navbar-toggler btn" type="button" data-toggle="collapse" data-target="#conteudoNavbarSuportado" aria-controls="conteudoNavbarSuportado" aria-expanded="false" aria-label="Alterna navegação">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="conteudoNavbarSuportado">
      <ul class=" nav navbar ml-auto">
        <li class="nav-item ">
          <a class="nav-link" href="#">UNIDADES</a>
        </li>
        <li class="nav-item  ">
          <a class="nav-link" href="#">ESPAÇO DO ALUNO</a>
        </li>
        <li class="nav-item  ">
          <a class="nav-link" href="#">AGENDE O SEU HORÁRIO</a>
        </li>
      </ul>
    </div>
  </nav>
</header>

<section class=" BOX - 1">
  <div class="container-fluid">
    <div class="row">
      <img src="https://www.seculodiario.com.br/images/u/171/b2ap3_large_03022015_incendio_leo_pora.gif" style="width: 99vw"/>
    </div>
  </div>
</section>

<section class=" BOX - 2">
  <div class="container part1">
    <h1>CONCEITO <span class="changeorange">JGYM</span></h1>

    <p class="sobrep"> Inaugurada em 2020, a JGYM foi criada com o propósito de democratizar o acesso à prática de atividade física de alto padrão, <span class="porange"> com planos acessíveis e adesão facilitada. </span> </p>
  </div>
</section>

<section class="descontos mb-2">
  <div class="container">
    <div class="row">
      <div class="col-12">
        <div class="card" style="width: 18rem;">
          <img src="https://img.icons8.com/all/500/google-logo.png" class="card-img-top" alt="...">
          <div class="card-body">
            <h5 class="card-title">Card title</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>
          </div>
          <ul class="list-group list-group-flush">
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Vestibulum at eros</li>
          </ul>
          <div class="card-body">
            <a href="#" class="card-link">Card link</a>
            <a href="#" class="card-link">Another link</a>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

Example using 2 cards

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">

<header>
  <nav class="navbar navbar-expand-md navbar-light bg-light  menu">
    <a class="navbar-brand" href="#"> <img src="https://getbootstrap.com.br/docs/4.1/assets/img/favicons/favicon-32x32.png" /></a>
    <button class="navbar-toggler btn" type="button" data-toggle="collapse" data-target="#conteudoNavbarSuportado" aria-controls="conteudoNavbarSuportado" aria-expanded="false" aria-label="Alterna navegação">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="conteudoNavbarSuportado">
      <ul class=" nav navbar ml-auto">
        <li class="nav-item ">
          <a class="nav-link" href="#">UNIDADES</a>
        </li>
        <li class="nav-item  ">
          <a class="nav-link" href="#">ESPAÇO DO ALUNO</a>
        </li>
        <li class="nav-item  ">
          <a class="nav-link" href="#">AGENDE O SEU HORÁRIO</a>
        </li>
      </ul>
    </div>
  </nav>
</header>

<section class="BOX-1">
  <div class="container-fluid">
    <div class="row">
      <img src="https://www.seculodiario.com.br/images/u/171/b2ap3_large_03022015_incendio_leo_pora.gif" style="width: 99vw"/>
    </div>
  </div>
</section>

<section class="BOX-2">
  <div class="container part1">
    <h1>CONCEITO <span class="changeorange">JGYM</span></h1>

    <p class="sobrep"> Inaugurada em 2020, a JGYM foi criada com o propósito de democratizar o acesso à prática de atividade física de alto padrão, <span class="porange"> com planos acessíveis e adesão facilitada. </span> </p>
  </div>
</section>

<section class="descontos mb-2">
  <div class="container">
    <div class="row">
      <div class="col">
        <div class="card">
          <img src="https://img.icons8.com/all/500/google-logo.png" class="card-img-top" alt="...">
          <div class="card-body">
            <h5 class="card-title">Card title</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>
          </div>
          <ul class="list-group list-group-flush">
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Vestibulum at eros</li>
          </ul>
          <div class="card-body">
            <a href="#" class="card-link">Card link</a>
            <a href="#" class="card-link">Another link</a>
          </div>
        </div>
      </div>
      <div class="col">
        <div class="card">
          <img src="https://img.icons8.com/all/500/google-logo.png" class="card-img-top" alt="...">
          <div class="card-body">
            <h5 class="card-title">Card title</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>
          </div>
          <ul class="list-group list-group-flush">
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Vestibulum at eros</li>
          </ul>
          <div class="card-body">
            <a href="#" class="card-link">Card link</a>
            <a href="#" class="card-link">Another link</a>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

Browser other questions tagged

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