How to format a Grid within Div?

Asked

Viewed 244 times

0

Gentlemen, I am trying to insert a grid inside my Divs, but it is in conflict with the top part, as image attached, follows an excerpt of my code where the problem occurs.

I have the div row1 which is the top and the div Problema Formatação Grid/Divrow2 which is the bottom.

#row1{
   height: 160px;
   width: 100%;
   margin-bottom:200px;
}

#row2{
   height: 160px;
   width: 100%;
   margin-bottom:200px;
}

.container {
   width: 500px;
   height: 160px;
   display: grid;
   grid-template-columns: 1fr 1fr;
   margin-left:100px;
   float:left;
   font-family: Arial, Helvetica, sans-serif;
   font-size: 20px;
   font-weight: bold;
   text-align: center;
}

.container div {
   display: flex;
   justify-content: center;
   align-items: center;
}

.rel, .acu {
   grid-column: span 2;
   background-color: white;
}

HTML:

<div id="row1">

    <c:if test ="${realizadoSG <metaSG}">
    <div class="container">
       <div class="marca" ><h1>SAMSUNG</h1></div> 
       <div class="meta">META: <fmt:formatNumber value = "${SG.rows[0].META}" type="currency"/></div>
       <div class="rel" style= "background-color: red; color: white;" >REALIZADO: <fmt:formatNumber 
        value = "${realizadoSG}" type="currency"/></div>
    <div class="acu">ACUMULADO: <c:out value="${SG.rows[0].ACUMULADO}"/>%</div>

</div>

<div id="row2">

    <c:if test ="${realizadoAS <metaAS}">
    <div class="container">
       <div class="marca"><h1>ASUS</h1></div> 
       <div class="meta"><h1>META:<fmt:formatNumber value= "${AS.rows[0].META}" type = "currency"/></h1></div>
       <div class="rel" style= "background-color: red; color: white;" >REALIZADO: <h1> <fmt:formatNumber 
      value= "${realizadoAS}" type = "currency"/></h1></div>
    <div class="acu">ACUMULADO:<h1><c:out value="${AS.rows[0].ACUMULADO}"/>%</h1></div>


</div>

1 answer

2

Your problem is probably here, forgot to close the tag div I will comment where it should be closed, inside the container follows with the correction

<div id="row1">

    <c:if test ="${realizadoSG <metaSG}">
    <div class="container">
       <div class="marca" ><h1>SAMSUNG</h1></div> 
       <div class="meta">META: <fmt:formatNumber value = "${SG.rows[0].META}" type="currency"/></div>
       <div class="rel" style= "background-color: red; color: white;" >REALIZADO: <fmt:formatNumber 
        value = "${realizadoSG}" type="currency"/></div>
    <div class="acu">ACUMULADO: <c:out value="${SG.rows[0].ACUMULADO}"/>%</div>
    </div><!--Falta essa tag -->

</div>

<div id="row2">

    <c:if test ="${realizadoAS <metaAS}">
    <div class="container">
       <div class="marca"><h1>ASUS</h1></div> 
       <div class="meta"><h1>META:<fmt:formatNumber value= "${AS.rows[0].META}" type = "currency"/></h1></div>
       <div class="rel" style= "background-color: red; color: white;" >REALIZADO: <h1> <fmt:formatNumber 
      value= "${realizadoAS}" type = "currency"/></h1></div>
    <div class="acu">ACUMULADO:<h1><c:out value="${AS.rows[0].ACUMULADO}"/>%</h1></div>
  </div><!--Falta essa tag -->

</div>

In css try this

#row1{
   height: 160px;
   width: 100%;
   margin-bottom:200px;
   clear: both;
   padding: 50px 0;
}

#row2{
   height: 160px;
   width: 100%;
   margin-bottom:200px;
   clear: both;
   padding: 50px 0;
}
  • the tag was already closed in my code, I ended up not inserting here, even so does not work...

  • Try then the new change I will make

  • Anderson, thanks for the help, I managed to adjust as I wanted, I added Padding-top:200px; in my row2, and the div was adjusted.

Browser other questions tagged

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