Adjust Div position in CSS and HTML

Asked

Viewed 961 times

2

I have a report that is mounted in html and css on A4 sheet size in landscape format. Everything works perfect. However I can’t align the tables on each other’s side. I want to Align all tables (Divs) below one another’s side:inserir a descrição da imagem aqui

CSS:

 body {
        background: rgb(204, 204, 204);
    }

page {
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}

    page[size="A4"] {
        width: 21cm;
        height: 29.7cm;
    }

        page[size="A4"][layout="portrait"] {
            width: 29.7cm;
            height: 21cm;
        }

@media print {
    body,
    page {
        margin: 0;
        box-shadow: 0;
    }
}

.header {
    padding-top: 10px;
    text-align: center;
    border: 2px solid #ddd;
}

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 80%;
}

    table th {
        background-color: #4caf50;
        color: white;
        text-align: center;
    }

th,
td {
    border: 1px solid #ddd;
    text-align: left;
}

tr:nth-child(even) {
    background-color: #f2f2f2
}

/* para definir a impressão no modo paisagem */
@page {
    size: landscape
}
.relativeEsquerda {
    position: relative;
    width: 200px;
    height: auto;
    border: solid #6AC5AC 3px;
}

.relativeProcesso {
    position: relative;
    left: 300px;
    width: 600px;
    height: auto;
    border: solid #6AC5AC 3px;
}

.relativeDireita {
    position: relative;
    left: 600px;
    width: 200px;
    height: auto;
    border: solid #6AC5AC 3px;
}

HTML:

<html>
<head>
    <link href="~/Areas/Qualidade/Css/RelatorioPaisagem.css" rel="stylesheet" />
</head>
<body>
    <div class="a4_vertical">
        <page size="A4">
            <img src="~/imagem/logo.png" />
            <div class="header">

                <h3>[DIAGRAMA DE PROCESSO] -  [QUALIDADE]</h3>
            </div>

            <div class="relativeEsquerda">
                <table class="table">
                    <thead>
                        <tr>
                            <th>Recursos de Materiais </th>
                        </tr>
                    </thead>
                    <tbody>
                        @{ for (int i = 0; i < ViewBag.listaMaterial.Count; i++)
                            {
                                <tr>
                                    <td>@ViewBag.listaMaterial[i].Descricao</td>
                                </tr>
                                cont++;
                            }
                        }

                </table>

                <table class="table">
                    <thead>
                        <tr>
                            <th>Interface Entrada </th>
                        </tr>
                    </thead>
                    <tbody>
                        @{ for (int i = 0; i < ViewBag.listaEntrada.Count; i++)
                            {
                                <tr>
                                    <td>@ViewBag.listaEntrada[i].Descricao</td>
                                </tr>
                                cont++;
                            }
                        }

                </table>
                <table class="table">
                    <thead>
                        <tr>
                            <th>Métodos/Processo/Técnica </th>
                        </tr>
                    </thead>
                    <tbody>
                        @{ for (int i = 0; i < ViewBag.listaMetodo.Count; i++)
                            {
                                <tr>
                                    <td>@ViewBag.listaMetodo[i].Descricao</td>
                                </tr>
                                cont++;
                            }
                        }

                </table>

            </div>

            <div class="relativeProcesso">
              <table class="table">
                    <thead>
                        <tr>
                            <th colspan="2">PROCESSO </th>
                        </tr>
                    </thead>
                    <tbody>
                        @{ for (int i = 0; i < ViewBag.listaProcesso.Count; i++)
                            {
                                <tr>
                                    @if(i == 0) {
                                         <td>P(Plan)</td>
                                    }
                                    <td>@ViewBag.listaProcesso[i].Plano</td>
                                </tr>
                                <tr>
                                    @if (i == 0)
                                    {
                                        <td>D(do)</td>
                                    }
                                    <td>@ViewBag.listaProcesso[i].Do_</td>
                                </tr>
                                <tr>
                                    @if (i == 0)
                                    {
                                        <td>C(Check)</td>
                                    }
                                    <td>@ViewBag.listaProcesso[i].Verifica</td>
                                </tr>
                                <tr>
                                    @if (i == 0)
                                    {
                                        <td>A(Action)</td>
                                    }
                                    <td>@ViewBag.listaProcesso[i].Acao</td>
                                </tr>
                                cont++;
                            }
                        }

</table>

            </div>
            <div class="relativeDireita">
                <table class="table">
                    <thead>
                        <tr>
                            <th>Recursos de Pessoal </th>
                        </tr>
                    </thead>
                    <tbody>
                        @{ for (int i = 0; i < ViewBag.listaRecursoPessoal.Count; i++)
                            {
                                <tr>
                                    <td>@ViewBag.listaRecursoPessoal[i].Descricao</td>
                                </tr>
                                cont++;
                            }
                        }

                </table>

                <table class="table">
                    <thead>
                        <tr>
                            <th>Interface Saída </th>
                        </tr>
                    </thead>
                    <tbody>
                        @{ for (int i = 0; i < ViewBag.listaSaida.Count; i++)
                            {
                                <tr>
                                    <td>@ViewBag.listaSaida[i].Descricao</td>
                                </tr>
                                cont++;
                            }
                        }

                </table>
                <table class="table">
                    <thead>
                        <tr>
                            <th>Medição/Monitoramento </th>
                        </tr>
                    </thead>
                    <tbody>
                        @{ for (int i = 0; i < ViewBag.listaMedicao.Count; i++)
                            {
                                <tr>
                                    <td>@ViewBag.listaMedicao[i].Descricao</td>
                                </tr>
                                cont++;
                            }
                        }

                </table>



            </div>


        </page>

        <page size="A4"></page>
        </div>
</body>
</html>
  • Already tried with float: left?

  • how would you look? would you put in all . relative?

  • it seems so, if those are the main Divs of the table.

1 answer

1


You can put display:inline-block in div and you have to take these left:300px / 600px

With this rule you take all the Ivs that start with "rela" and put the display to stay in line

[class^="rela"] { display: inline-block; }

See below the corrected code:

 body {
        background: rgb(204, 204, 204);
    }

page {
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}

    page[size="A4"] {
        width: 21cm;
        height: 29.7cm;
    }

        page[size="A4"][layout="portrait"] {
            width: 29.7cm;
            height: 21cm;
        }

@media print {
    body,
    page {
        margin: 0;
        box-shadow: 0;
    }
}

.header {
    padding-top: 10px;
    text-align: center;
    border: 2px solid #ddd;
}

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 80%;
}

    table th {
        background-color: #4caf50;
        color: white;
        text-align: center;
    }

th,
td {
    border: 1px solid #ddd;
    text-align: left;
}

tr:nth-child(even) {
    background-color: #f2f2f2
}

/* para definir a impressão no modo paisagem */
@page {
    size: landscape
}
.relativeEsquerda {
    position: relative;
    width: 200px;
    height: auto;
    border: solid #6AC5AC 3px;
}

.relativeProcesso {
    position: relative;
    /* left: 300px; */
    width: 600px;
    height: auto;
    border: solid #6AC5AC 3px;
}

.relativeDireita {
    position: relative;
    /* left: 600px; */
    width: 200px;
    height: auto;
    border: solid #6AC5AC 3px;
}

[class^="rela"] {
    display: inline-block;
    float: left;
}
<div class="a4_vertical">
        <page size="A4">
            <img src="~/imagem/logo.png" />
            <div class="header">

                <h3>[DIAGRAMA DE PROCESSO] -  [QUALIDADE]</h3>
            </div>

            <div class="relativeEsquerda">
                <table class="table">
                    <thead>
                        <tr>
                            <th>Recursos de Materiais </th>
                        </tr>
                    </thead>
                    <tbody>
                       
                                <tr>
                                    <td>@ViewBag.listaMaterial[i].Descricao</td>
                                </tr>
               
                </table>

                <table class="table">
                    <thead>
                        <tr>
                            <th>Interface Entrada </th>
                        </tr>
                    </thead>
                    <tbody>
                        
                                <tr>
                                    <td>@ViewBag.listaEntrada[i].Descricao</td>
                                </tr>
                           

                </table>
                <table class="table">
                    <thead>
                        <tr>
                            <th>Métodos/Processo/Técnica </th>
                        </tr>
                    </thead>
                    <tbody>
                       
                                <tr>
                                    <td>@ViewBag.listaMetodo[i].Descricao</td>
                                </tr>
                               

                </table>

            </div>

            <div class="relativeProcesso">
              <table class="table">
                    <thead>
                        <tr>
                            <th colspan="2">PROCESSO </th>
                        </tr>
                    </thead>
                    <tbody>
                        
                                <tr>
                                   
                                         <td>P(Plan)</td>
                                    
                                    <td>@ViewBag.listaProcesso[i].Plano</td>
                                </tr>
                                <tr>
                                   
                                        <td>D(do)</td>
                                    
                                    <td>@ViewBag.listaProcesso[i].Do_</td>
                                </tr>
                                <tr>
                                   
                                        <td>C(Check)</td>
                                    
                                    <td>@ViewBag.listaProcesso[i].Verifica</td>
                                </tr>
                                <tr>
                                   
                                        <td>A(Action)</td>
                                    
                                    <td>@ViewBag.listaProcesso[i].Acao</td>
                                </tr>
                       

</table>

            </div>
            <div class="relativeDireita">
                <table class="table">
                    <thead>
                        <tr>
                            <th>Recursos de Pessoal </th>
                        </tr>
                    </thead>
                    <tbody>
                       
                                <tr>
                                    <td>@ViewBag.listaRecursoPessoal[i].Descricao</td>
                                </tr>
                               

                </table>

                <table class="table">
                    <thead>
                        <tr>
                            <th>Interface Saída </th>
                        </tr>
                    </thead>
                    <tbody>
                       
                                <tr>
                                    <td>@ViewBag.listaSaida[i].Descricao</td>
                                </tr>
                                

                </table>
                <table class="table">
                    <thead>
                        <tr>
                            <th>Medição/Monitoramento </th>
                        </tr>
                    </thead>
                    <tbody>
                       
                                <tr>
                                    <td>@ViewBag.listaMedicao[i].Descricao</td>
                                </tr>
                                

                </table>



            </div>


        </page>

        <page size="A4"></page>
        </div>

inserir a descrição da imagem aqui

  • I’ll try it out ... Thank you

  • @Daniellearrudatorres here testing in Chrome worked, but test there to see if there is no detail to fix

  • Right... Thanks. Now I will adjust layout to look cute. put soon, change color... etc..

  • @Daniellearrudatorres this there, makes the "final art" now to be cool, qq another doubt put there that always has someone to help [] s

Browser other questions tagged

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