Position problem in hidden div

0

I have a problem that is difficult to explain, so I leave as much data as possible.

Clarification: I'm using bootstrap.

First I share an image of the area in question

Clicking on the magnifying glass activates a toggler that displays the input search engine. My idea is that once done enter / click in Search, the results of the search are shown in a div that is hidden on RECOMMENDED. This is not toggler because I reload the page to make the php request, it's just an empty div that fills up to show the search results.

The problem is that when this div appears, it literally breaks all the styles that I already have armed.

I do not really know where a div starts and where the other begins. I simply want it to be shown one above the other, that the REC RECOMMENDED div moves down to show the results of the search in the first place.

Now if I leave code. First the css involved and then the html / php:

#rightCol {
  background: #b57d29;
  margin-top: 1vw;
  border: 0.25vw solid #4d0000;
}

.miniLibro {
  width: 250px;
  height: 400px;
  background-size: 100% 100%;
  float: left;
  margin-bottom: 3%;
  transition: 0.5s;
  color: #ffffff;
}

.miniLibro:hover {
  cursor: pointer;
  filter: brightness(130%);
}

.titulo {
  position: relative;
  height: 42px;
  background: #000000;
  filter: opacity(80%);
  font-size: 0.9em;
  text-align: center;
}

.stock {
  position: relative;
  margin-top: 131.1%;
  transition: 0.5s;
  font-size: 1em;
}

.precio {
  position: relative;
  text-align: center;
  font-size: 1.3em;
  float: right;
  border-radius: 40%;
  width: 26%;
  margin-top: -12.5%;
  background-color: #b71f1f;
  transition: 0.5s;
}

.miniLibro:hover>.precio {
  filter: brightness(80%);
}

.enStock {
  background-color: #173019;
  width: 35%;
  text-align: left;
  height: 30px;
  border-radius: 0 90% 0 0;
}

.pocoStock {
  background-color: #e09e02;
  text-align: left;
  width: 35%;
  height: 30px;
  border-radius: 0 90% 0 0;
}

.agotado {
  background-color: #e03901;
  text-align: left;
  width: 35%;
  height: 30px;
  border-radius: 0 90% 0 0;
}

.miniLibro:hover>.stock {
  filter: brightness(80%);
}
<div class="container">
  <div class="row">
    <div id="leftCol" class="col-lg-4">
    </div>
    <div id="rightCol" class="col-lg-8">

      <?php 
          if (isset($_POST['buscar'])) {
            require 'conexion.php';
            $src = $_POST['src'];
            $consulta = "
              SELECT titulo, imagen, categoria, precio, cantidad
              FROM lecturas_db.inventario
              WHERE titulo LIKE '%$src%'
            ";
            $resultado = mysqli_query($conexion,$consulta);
            $direct = 'img/cover/'; 
         /* $_SERVER['DOCUMENT_ROOT'].'/Lecturas Comics/ agregar para ruta completa */
            if (!$resultado) {
              echo "Error";
            }
            else { ?>
      <div class="container">
        <h2 align="center">
          <?php
                if(mysqli_num_rows($resultado)>0) {
                  echo "Mostrando resultados para '".$_POST['src']."'.";
                 } else {
                   echo "No hay resultados para '".$_POST['src']."'.";
                 } ?>
        </h2>
        <?php
              while($row = mysqli_fetch_array($resultado)) {
                if($row['categoria'] == 'proximamente') { ?>
          <a href="busProx.php?titulo=<?php echo $row['titulo'] ?>">
             <div
               style="background-image: url('<?php echo $direct.$row["imagen"] ?>')"
               class="miniLibro">
                 <div class="titulo" align="center">
                   <b><?php echo $row['titulo'] ?></b>
                 </div>
                 <div class="stock" align="left">
                   <div class="proximamente"> <b>
                          Próximamente
                        </b></div>
                 </div>
               </div>
          </a>
          <?php } else { ?>
          <a href="busLibro.php?titulo=<?php echo $row['titulo'] ?>">
            <div
              style="background-image: url('<?php echo $direct.$row["imagen"] ?>')"
              class="miniLibro">
              <div class="titulo" align="center">
                <b><?php echo $row['titulo'] ?></b>
              </div>
              <div class="stock" align="left">
                <b><?php if($row['cantidad'] > '3') { ?>
                <div class="enStock">En Stock</div> 
                  <?php } if($row['cantidad'] <= '3' && $row['cantidad'] > '0') { ?>
                <div class="pocoStock">
                  <?php echo $row['cantidad'] ?> en Stock
                </div>
                <?php } if($row['cantidad'] == '0') { ?>
                <div class="agotado">Agotado</div>
                <?php } ?>
                </b>
              </div>
              <div class="precio" align="right">
                <b><?php echo "$".$row['precio'] ?></b>
              </div>
            </div>
            <?php } ?>
          </a></div><br>
      <?php }
            }
          }
         ?>
      <div class="container">
        <h1 align="center"><b>RECOMENDADOS</b></h1><br>
        <?php
          require 'conexion.php';
          $direct = 'img/cover/';
          $sql = "
            SELECT titulo, imagen, precio, cantidad
            FROM lecturas_db.inventario
            WHERE categoria = 'recomendado' ORDER BY titulo ASC
          ";
          $resultado = mysqli_query($conexion,$sql);
          while ($row = mysqli_fetch_array($resultado)) { ?>
          <a href="busLibro.php?titulo=<?php echo $row['titulo'] ?>">
          <div 
            style="background-image: url('<?php echo $direct.$row["imagen"] ?>')"
            class="miniLibro">
              <div class="titulo" align="center">
                <b><?php echo $row['titulo'] ?></b>
              </div>
              <div class="stock" align="left">
                <b><?php if($row['cantidad'] > '3') { ?>
                  <div class="enStock">
                    En Stock
                  </div> 
                <?php } if($row['cantidad'] <= '3' && $row['cantidad'] > '0') { ?>
                  <div class="pocoStock">
                    <?php echo $row['cantidad'] ?> en Stock
                  </div>
                <?php } if($row['cantidad'] == '0') { ?>
                  <div class="agotado">
                    Agotado
                  </div>
                <?php }
                ?></b>
              </div>
              <div class="precio" align="right">
                <b><?php echo "$".$row['precio'] ?></b>
              </div>
            </div>
        <?php } ?>
          </a>
      </div>
    </div>

  </div>
</div>

Update : After carefully reviewing the code in case I had left some div open or closed more, and after not finding an error, I decided to check the location of the containers from the same browser and these they are perfectly located, one on top of the other.

The problem is that the content of these containers goes out. I show you

That is the container of my search, see how the container is well located but the book is on the outside. Now I show you the next container.

See how in reality only the title marks me.

    
asked by Juan enriquez 01.01.2019 в 22:13
source

1 answer

0

To begin with there should not be two divs with the container class. If you could the final code of that section would be good, you could place the two coni, although you could try this logic, look how I would do it: link

You can base yourself on that code, I have corrected some css rules so that it is responsive since you had some errors, I hope to serve you

#leftCol {
  height: auto;
  width: 100%;
  background: red; /*Pon tu color o eliminar si no quieres color de fondo*/
  
}
#rightCol {
  background: #b57d29;
}

.miniLibro {
  width: 100%;
  height: auto;
  background-size: 100% 100%;
  float: left;
  margin-bottom: 3%;
  transition: 0.5s;
  color: #ffffff;
}

.miniLibro:hover {
  cursor: pointer;
  filter: brightness(130%);
}

.titulo {
  position: relative;
  height: 42px;
  background: #000000;
  filter: opacity(80%);
  font-size: 0.9em;
  text-align: center;
}

.stock {
  position: relative;
  margin-top: 131.1%;
  transition: 0.5s;
  font-size: 1em;
}

.precio {
  position: relative;
  text-align: center;
  font-size: 1.3em;
  float: right;
  border-radius: 40%;
  width: 26%;
  margin-top: -12.5%;
  background-color: #b71f1f;
  transition: 0.5s;
}

.miniLibro:hover>.precio {
  filter: brightness(80%);
}

.enStock {
  background-color: #173019;
  width: 35%;
  text-align: left;
  height: 30px;
  border-radius: 0 90% 0 0;
}

.pocoStock {
  background-color: #e09e02;
  text-align: left;
  width: 35%;
  height: 30px;
  border-radius: 0 90% 0 0;
}

.agotado {
  background-color: #e03901;
  text-align: left;
  width: 35%;
  height: 30px;
  border-radius: 0 90% 0 0;
}

.miniLibro:hover>.stock {
  filter: brightness(80%);
}
<div class="container">
<div class="row">
  <div id="leftCol" class="col-sm-4 col-md-4 col-lg-4">
    Izquierda
  </div>
  <div id="rightCol" class="col-sm-8 col-md-8 col-lg-8">
    <!-- Seccion busqueda -->
    <div class="row">
      <div class="col-12">
        <h3>Resultado de busqueda</h3>
      </div>      
    </div>
    <div class="row">
      
      <!-- Muestra para mostrar imprimir con PHP -->
      <div class="col-12 col-sm-6 col-md-6 col-lg-4">
        <a href="#titulo">
          <div style="background-image: url(https://m.media-amazon.com/images/M/MV5BOTM3NzE5OTE1Nl5BMl5BanBnXkFtZTgwNzQwNjM3NjM@._V1_SY1000_CR0,0,674,1000_AL_.jpg)" class="miniLibro">
            <div class="titulo" align="center">
              <b>Blumblebee</b>
            </div>
            <div class="stock" align="left">
              <div class="proximamente">
                <b>Próximamente</b>
              </div>
            </div>
          </div>
        </a>
      </div>
      <!-- Fin muestra para mostrar imprimir con PHP -->

      <div class="col-12 col-sm-6 col-md-6 col-lg-4">
        <a href="#titulo">
          <div style="background-image: url(https://m.media-amazon.com/images/M/MV5BOTM3NzE5OTE1Nl5BMl5BanBnXkFtZTgwNzQwNjM3NjM@._V1_SY1000_CR0,0,674,1000_AL_.jpg)" class="miniLibro">
            <div class="titulo" align="center">
              <b>Blumblebee</b>
            </div>
            <div class="stock" align="left">
              <div class="proximamente">
                <b>Próximamente</b>
              </div>
            </div>
          </div>
        </a>
      </div>
      <div class="col-12 col-sm-6 col-md-6 col-lg-4">
        <a href="#titulo">
          <div style="background-image: url(https://m.media-amazon.com/images/M/MV5BOTM3NzE5OTE1Nl5BMl5BanBnXkFtZTgwNzQwNjM3NjM@._V1_SY1000_CR0,0,674,1000_AL_.jpg)" class="miniLibro">
            <div class="titulo" align="center">
              <b>Blumblebee</b>
            </div>
            <div class="stock" align="left">
              <div class="proximamente">
                <b>Próximamente</b>
              </div>
            </div>
          </div>
        </a>
      </div>
      <div class="col-12 col-sm-6 col-md-6 col-lg-4">
        <a href="#titulo">
          <div style="background-image: url(https://m.media-amazon.com/images/M/MV5BOTM3NzE5OTE1Nl5BMl5BanBnXkFtZTgwNzQwNjM3NjM@._V1_SY1000_CR0,0,674,1000_AL_.jpg)" class="miniLibro">
            <div class="titulo" align="center">
              <b>Blumblebee</b>
            </div>
            <div class="stock" align="left">
              <div class="proximamente">
                <b>Próximamente</b>
              </div>
            </div>
          </div>
        </a>
      </div>
      <div class="col-12 col-sm-6 col-md-6 col-lg-4">
        <a href="#titulo">
          <div style="background-image: url(https://m.media-amazon.com/images/M/MV5BOTM3NzE5OTE1Nl5BMl5BanBnXkFtZTgwNzQwNjM3NjM@._V1_SY1000_CR0,0,674,1000_AL_.jpg)" class="miniLibro">
            <div class="titulo" align="center">
              <b>Blumblebee</b>
            </div>
            <div class="stock" align="left">
              <div class="proximamente">
                <b>Próximamente</b>
              </div>
            </div>
          </div>
        </a>
      </div>
      <div class="col-12 col-sm-6 col-md-6 col-lg-4">
        <a href="#titulo">
          <div style="background-image: url(https://m.media-amazon.com/images/M/MV5BOTM3NzE5OTE1Nl5BMl5BanBnXkFtZTgwNzQwNjM3NjM@._V1_SY1000_CR0,0,674,1000_AL_.jpg)" class="miniLibro">
            <div class="titulo" align="center">
              <b>Blumblebee</b>
            </div>
            <div class="stock" align="left">
              <div class="proximamente">
                <b>Próximamente</b>
              </div>
            </div>
          </div>
        </a>
      </div>
    </div>
    <!-- Fin Seccion busqueda -->

    <!-- Recomendados -->
    <div class="row">
      <div class="col-12">
        <h3>Recomendados</h3>
     </div>      
    </div>
    <div class="row">

      <!-- Muestra para mostrar imprimir con PHP -->
      <div class="col-12 col-sm-6 col-md-6 col-lg-4">
        <a href="#titulo">
          <div style="background-image: url(https://m.media-amazon.com/images/M/MV5BOTM3NzE5OTE1Nl5BMl5BanBnXkFtZTgwNzQwNjM3NjM@._V1_SY1000_CR0,0,674,1000_AL_.jpg)" class="miniLibro">
            <div class="titulo" align="center">
              <b>Blumblebee</b>
            </div>
            <div class="stock" align="left">
              <div class="proximamente">
                <b>Próximamente</b>
              </div>
            </div>
          </div>
        </a>
      </div>
      <!-- Fin muestra para mostrar imprimir con PHP -->

    </div>
    <!-- Recomendados -->
  </div>
</div>
</div>

Update 1: In theory there should only be one div with the container class, it would be the parent div that would cover everything, inside you can put all the divs (header, nav, side, section , article, footer) that you want. Not necessarily the div must contain the row class, you can use it so that you do not get confused, div with its respective id="divBusqueda" id="divRecomendados" so you just want to identify it and show it with PHP, I'll leave you an example, I hope you answer your concern

<div class="container">

  <!-- rightCol -->
  <div id="rightCol" class="col-sm-8 col-md-8 col-lg-8">

    <!-- Section Busqueda -->
    <div id="divBusqueda">

      <!-- Muestra para mostrar imprimir con PHP -->
      <div class="col-12 col-sm-6 col-md-6 col-lg-4">
        <a href="#titulo">
          <div style="background-image: url(https://m.media-amazon.com/images/M/MV5BOTM3NzE5OTE1Nl5BMl5BanBnXkFtZTgwNzQwNjM3NjM@._V1_SY1000_CR0,0,674,1000_AL_.jpg)" class="miniLibro">
            <div class="titulo" align="center">
              <b>Blumblebee</b>
            </div>
            <div class="stock" align="left">
              <div class="proximamente">
                <b>Próximamente</b>
              </div>
            </div>
          </div>
        </a>
      </div>
      <!-- Fin muestra para mostrar imprimir con PHP -->

    </div>
    <!-- Section Busqueda -->

    <!-- Section Recomendados -->
    <div id="divRecomentados">

      <!-- Muestra para mostrar imprimir con PHP -->
      <div class="col-12 col-sm-6 col-md-6 col-lg-4">
        <a href="#titulo">
          <div style="background-image: url(https://m.media-amazon.com/images/M/MV5BOTM3NzE5OTE1Nl5BMl5BanBnXkFtZTgwNzQwNjM3NjM@._V1_SY1000_CR0,0,674,1000_AL_.jpg)" class="miniLibro">
            <div class="titulo" align="center">
              <b>Blumblebee</b>
            </div>
            <div class="stock" align="left">
              <div class="proximamente">
                <b>Próximamente</b>
              </div>
            </div>
          </div>
        </a>
      </div>
      <!-- Fin muestra para mostrar imprimir con PHP -->
    </div>
    <!-- Fin Section Recomendados -->

  </div>
  <!-- rightCol -->
</div>
    
answered by 02.01.2019 / 09:54
source