I was trying to take an exercise and create an advanced layout as shown below.
After I came up with two solutions I started to wonder what is the best solution for creating such a layout.
Would you use flex display or table display? Would you consider using bootstrap or not? What should I consider when choosing one over the other in this case? Also taking in consideration devices with smaller resolution, for example 800px or less.
Here are my implementations:
Flex implementation:
<div class="container p-0">
<div class="d-flex flex-row bd-highlight">
<div class="flex-grow-1 bd-highlight">
<div class="mt-3 ml-3">
#C0000028524
</div>
</div>
<div class="flex-grow-10 bd-highlight d-flex long-title-container">
<div class="mt-3 long-title">
<p class="long-title mb-0 fs-5">
Context menu shows wrong language
</p>
</div>
</div>
<div class="flex-grow-1 bd-highlight text-secondary">last updated</div>
</div>
<div class="d-flex flex-row bd-highlight">
<div class="flex-grow-1 bd-highlight mlm-1">
<img src="open.png" />
</div>
<div class="flex-grow-10 bd-highlight d-flex long-title-container"><p class="long-title">Context menu shows wrong language</p></div>
<div class="flex-grow-1 bd-highlight text-secondary">last updated</div>
</div>
</div>
Link to the flex implementation: https://jsfiddle.net/7d512swt/
And here is my table implementation:
<div class="table-responsive">
<table class="table">
<tbody>
<tr>
<th scope="row">
<div class="mt-3 ml-3">
#C0000028524
</div>
</th>
<td>
<p class="long-title mb-0 fs-5">
Context menu shows wrong language
</p>
</td>
<td>last updated</td>
</tr>
<tr>
<th scope="row">2</th>
<td><img src="open.png" /></td>
<td><p class="long-title">Context menu shows wrong language</p></td>
<td>last updated</td>
</tr>
</tbody>
</table>
</div>
Link to the table implementation:
https://jsfiddle.net/auv08hdq/
Related
*Here is the code. With this code listing is done vertically.Here is the current output I want to make this vertically.
*This is the current code I written.
{% extends 'index.html' %}
{%block body_block%}
{%for p in carslist%}
<section class="py-5">
<div class="container px-4 px-lg-5 mt-2">
<div class="row gx-4 gx-lg-5 row-cols-2 row-cols-md-3 row-cols-xl-4 justify-content-center">
<div class="col mb-5">
<div class="card h-100">
<!-- Product image-->
<img class="card-img-top" src="{{p.carpic.url}}" alt="..." />
<!-- Product details-->
<div class="card-body p-4">
<div class="text-center">
<!-- Product name-->
<h5 class="fw-bolder">{{p.carcompany}}</h5>
<p>{{p.carmodel}}</p>
<!-- Product price-->
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">Price: {{p.carprice}}</li>
<li class="list-group-item">Kms: {{p.carkms}}</li>
</ul>
</div>
<!-- Product actions-->
<div class="card-footer p-4 pt-0 border-top-0 bg-transparent">
<div class="text-center"><a class="btn btn-outline-dark mt-auto" href="#">View Details</a></div>
</div>
</div>
</div>
</div>
</div>
</section>
{%endfor%}
For the parent element of each of your products, you need to write the properties: display: flex;
flex direction: row;
flex-wrap: wrap;
In tailwind - flex flex-row flex-wrap
simply remove all the row-cols classes and things should stack up vertically by default.
Classes to remove: row-cols-2 row-cols-md-3 row-cols-xl-4.
When you have a lot of cluttered html like that and you can't make sense of it anymore I find that the best way to go about it is to reduce the structure to the very minimum, and build from there.
Comment your code and rebuild it little step by little step. Then you can see the impact of each individual element or class that you add.
I need the boxes aligned at right also vertically aligned with the first box at left, but now these boxes are only aligned with the last vertical box at the left. How can I achieve that?
starter.component.html code:
<div class="card" *ngIf="loading"><div class="card-body pt-0"><div class="k-i-loading">Carregando informaçães do dashboard...</div></div></div>
<div class="row" *ngxPermissionsOnly="['GERENTE_FINANCEIRO', 'ADMINISTRATIVO_FINANCEIRO']">
<div class="col-lg-8 col-md-8 col-sm-8">
<detalhes-titulos [titulos]="titulosDespesaData" [tipo]="DESPESA" [loading]="loading"></detalhes-titulos>
</div>
<div class="col-lg-8 col-md-8 col-sm-8">
<detalhes-titulos [titulos]="titulosDespesaData" [tipo]="DESPESA" [loading]="loading"></detalhes-titulos>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div *ngFor="let item of contasData" class="card col-lg-12 col-md-12 col-sm-12">
<div class="card-body">
<h6 class="text-muted m-t-10 m-b-0"><span style="background: #56c0d8;" class="lstick"></span>{{ item.nome }}</h6>
<h2 [ngClass]="{'text-info': item.saldo > 0, 'text-danger': item.saldo < 0}">{{ item.saldo | currency:'BRL':'symbol':'1.2-2':'pt' }}</h2>
</div>
</div>
</div>
</div>
starter-detalhes-titulos.component.html
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="card">
<div class="card-body">
<div class="d-flex no-block">
<div>
<h4 class="card-title"><span style="background: #56c0d8;" class="lstick"></span>Títulos a {{ tipo === 0 ? 'receber' : 'pagar'}} nos próximos 10 dias</h4>
</div>
</div>
<div class="table-responsive m-t-20" *ngIf="titulos.length > 0">
<table class="table vm no-th-brd pro-of-month">
<thead>
<tr>
<th>Número</th>
<th class="text-center">Emissão</th>
<th class="text-center">Vencimento</th>
<th class="text-right">Valor</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of titulos">
<td><span class="p-1 text-white font-weight-bold rounded small vitai-bg-color">{{ item.numero }}</span></td>
<td class="text-center">{{ item.emissao | date:"dd/MM/yyyy" }}</td>
<td class="text-center">{{ item.vencimento | date:"dd/MM/yyyy" }}</td>
<td class="text-right text-info" *ngIf="item.natureza === 0">{{ item.valor | currency:'BRL':'symbol':'1.2-2':'pt' }}</td>
<td class="text-right text-danger" *ngIf="item.natureza === 1">- {{ item.valor | currency:'BRL':'symbol':'1.2-2':'pt' }}</td>
</tr>
</tbody>
</table>
</div>
<div class="table-responsive m-t-20" *ngIf="titulos.length === 0">
<table class="table vm no-th-brd pro-of-month">
<tbody>
<tr>
<td class="text-center" *ngIf="loading">Carregando títulos a {{ tipo === 0 ? 'receber' : 'pagar'}} nos próximos dez dias.</td>
<td class="text-center" *ngIf="!loading">Nenhum título a {{ tipo === 0 ? 'receber' : 'pagar'}} encontrado nos próximos dez dias.</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
EDIT:
If I change starter.component.html code to:
<div class="card" *ngIf="loading"><div class="card-body pt-0"><div class="k-i-loading">Carregando informaçães do dashboard...</div></div></div>
<div class="row" *ngxPermissionsOnly="['GERENTE_FINANCEIRO', 'ADMINISTRATIVO_FINANCEIRO']">
<div class="col-lg-8 col-md-8 col-sm-8">
<detalhes-titulos [titulos]="titulosDespesaData" [tipo]="DESPESA" [loading]="loading"></detalhes-titulos>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div *ngFor="let item of contasData" class="card col-lg-12 col-md-12 col-sm-12">
<div class="card-body">
<h6 class="text-muted m-t-10 m-b-0"><span style="background: #56c0d8;" class="lstick"></span>{{ item.nome }}</h6>
<h2 [ngClass]="{'text-info': item.saldo > 0, 'text-danger': item.saldo < 0}">{{ item.saldo | currency:'BRL':'symbol':'1.2-2':'pt' }}</h2>
</div>
</div>
</div>
<div class="col-lg-8 col-md-8 col-sm-8">
<detalhes-titulos [titulos]="titulosDespesaData" [tipo]="DESPESA" [loading]="loading"></detalhes-titulos>
</div>
</div>
I get the following layout which could be almost what I want:
Now I just need the second box at left closer to the first one.
Well you need to define what you want here.
Simply putting top-left box and the bottom-left box in the 8/12 column and those little boxes on the right in the 4/12 column will fix your problem:
<div class="row">
<div class="col-sm-8">
<detalhes-titulos [titulos]="titulosDespesaData" />
<detalhes-titulos [titulos]="titulosDespesaData" />
</div>
<div class="col-sm-4">
<div *ngFor="" class="card">
...
</div>
</div>
</div>
But I don't know if that's what you want, especially you didn't define what you want for different breakpoints.
This question already has answers here:
Vertical Align Center in Bootstrap 4 [duplicate]
(20 answers)
Closed 3 years ago.
i'm trying to vertically center a row which contains a card, I tried all solutions in this question's solution Vertical Align Center in Bootstrap 4
but absolutely nothing happens.
Here is my html code :
<div class="row h-100">
<mat-progress-spinner id="loader" style="top: 50%; left: 47%; transform: translate(-50%, -50%); position:absolute; z-index: 1;" *ngIf="showLoading"
[color]="color"
[mode]="mode">
</mat-progress-spinner>
<div class="col-sm-12 my-auto">
<div *ngIf="app" class="card card-block shadow text-center mx-auto">
<div class="card-header">
<h1>{{app.name | uppercase}}</h1>
</div>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Micro Service</th>
<th scope="col">Status</th>
<th scope="col">Actions</th>
<th scope="col">Settings</th>
</tr>
<tbody>
<tr *ngFor="let ms of app.microservices">
<td style="width: 25%" class="align-middle" id="msname">{{ms.name}}</td>
<td style="width: 25%" class="align-middle">
<img *ngIf="(isContainerRunning | async)" src="../../../assets/img/running.png" width="50px" height="50px" matTooltipPosition="right" matTooltip="Running">
<img *ngIf="!(isContainerRunning | async)" src="../../../assets/img/exited.png" width="50px" height="50px" matTooltipPosition="right" matTooltip="Exited">
</td>
<td style="width: 25%" class="align-middle">
<a (click)="start(ms.name)"><img src="../../../assets/img/start.png" height="50px" width="50px" class="settings mx-auto" appSelector></a>
<a (click)="stop(ms.name)"><img src="../../../assets/img/stop.png" height="50px" width="50px" class="settings mx-auto" appSelector></a>
<a (click)="restart(ms.name)"><img src="../../../assets/img/restart.png" height="50px" width="50px" class="settings mx-auto" appSelector></a>
</td>
<td style="width: 25%" class="align-middle">
<button (click)="redirect(ms_url)" id="backbtn">edit</button>
</td>
</tr>
<tr>
<td colspan="4" class="text-center align-middle"><button (click)="back()" id="backbtn">back</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
ps : this is an angular project so the container is in another component here is the container tag :
<div class="container-fluid h-100">
<div [#routeAnimations]="prepareRoute(outlet)">
<router-outlet #outlet="outlet"></router-outlet>
</div>
</div>
It seems like "my-auto" and every single other solutions has no impact on my card position.
EDIT :
i'm using angular material sidenav which is configured in main app.component.html like, not sure if it changes anything tho :
<mat-sidenav-container>
<mat-sidenav mode="side" opened (mouseenter)="toggleMenu()" (mouseleave)="toggleMenu()">
<table class="w-100 mx-auto text-center">
<tr>
<td>
<img src="../assets/img/logo.png" width="60px" class="py-2 px-2 my-3" id="logoaxians">
</td>
</tr>
<tr>
<td>
<a routerLink="/applications" routerLinkActive="active" matTooltipPosition="right" matTooltip="Applications"><img src="../assets/img/dashboard.png" width="43px" class="py-2 px-2 icons"></a>
</td>
</tr>
</table>
<table class="w-100 mx-auto text-center" id="bottomnav">
<tr>
<td>
<a routerLink="/help" routerLinkActive="active" mat-raised-button matTooltipPosition="right" matTooltip="Help"><img src="../assets/img/help.png" width="50px" class="py-2 px-2 icons"></a>
</td>
</tr>
</table>
</mat-sidenav>
<mat-sidenav-content>
<div class="container-fluid vh-100">
<div [#routeAnimations]="prepareRoute(outlet)">
<router-outlet #outlet="outlet"></router-outlet>
</div>
</div>
</mat-sidenav-content>
</mat-sidenav-container>
Thanks for your help.
try this :
<div class="container-fluid h-100">
<div [#routeAnimations]="prepareRoute(outlet)" class="h-100">
<router-outlet #outlet="outlet"></router-outlet>
</div>
</div>
My web application has some areas placed in the page. Basically:
<body>
<nav> <-- top nav bar
<ol> <-- breadcrumb
<div> <-- row with buttons
<div class="overflow-auto">
<table> <-- run-time growing table
</div>
<footer> <-- sticky footer
</body>
At run-time my scripts add rows to the table.
To get the overflow-auto class working I have to set a max-height value.
If I set it to 100% it just grows like without overflow. It works if I set a px value only.
My goal, instead, is to fill all the available space (so it depends on the browser, width, etc...) between the previous div (row with buttons) and the sticky footer.
In other words, I want the user always sees the footer so when the table reach it, the overflow feature should begin to work.
I don't understand if this can be easily handled with some specific classes or I have to manually compute the available height (if even possible...).
UPDATE
I cannot manage it to work with a sidebar. Complete code:
<body class="vh-100 d-flex flex-column overflow-hidden">
<nav id="nav_top" class="navbar navbar-expand navbar-dark bg-dark static-top">
<ul class="navbar-nav d-none d-md-inline-block form-inline ml-auto mr-0 mr-md-3 my-2 my-md-0">
<li class="nav-item">
<h5>
<span class="badge badge-secondary">BLABLA</span>
</h5>
</li>
</ul>
</nav>
<div id="wrapper">
<ul class="sidebar navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="index.php">
<span>NAV 1</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php">
<span>NAV 2</span>
</a>
</li>
</ul>
<div id="content-wrapper">
<div class="container-fluid">
<ol class="breadcrumb">
<li class="breadcrumb-item">
Home
</li>
<li class="breadcrumb-item active">Current page</li>
</ol>
<button type="button" class="btn btn-info mb-3">BUTTON</button>
<div id="content" class="row overflow-auto">
<div class="col-12 table-responsive">
<table id="tableParameters" class="table table-sm">
<thead class="thead-light">
<tr>
<th scope="col">COL 1</th>
<th scope="col">COL 2</th>
<th scope="col">COL 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>table</td>
<td>table</td>
<td>table</td>
</tr>
<tr>
<td>table</td>
<td>table</td>
<td>table</td>
</tr>
<tr>
<td>table</td>
<td>table</td>
<td>table</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</body>
It's not clear to me what affect the overflow-auto behavior. I need the row/col divs in order to keep margins.
I think you'd want to use flexbox for this...
<body class="vh-100 d-flex flex-column overflow-hidden">
<nav> <-- top nav bar -->
<ol> <-- breadcrumb -->
<div> <-- row with buttons -->
<div class="overflow-auto">
<table> <-- run-time growing table -->
</div>
<footer class="mt-auto"> <-- sticky footer -->
</body>
vh-100 - makes the entire body viewport height
d-flex flex-column - make the body display:flex, flex-direction:column
overflow-hidden - prevents the body from scrolling
mt-auto - to make the footer stick the the bottom
Demo: https://www.codeply.com/go/FSrBOdRVFG
Basically this has been answered before:
Bootstrap 4 row fill remaining height
How to make the row stretch remaining height
Bootstrap 4: Scrollable row, which fills remaining height
All of a sudden, these 3 dropdown boxes I have on my home page stopped responding. I feel like I'm going crazy and just not able to figure it out. Code is below.
I have 3 boxes that contain tables that are revealed on click. However, they are not revealing. They should look like this when clicked.
The website is thrivematching.com if you need to check it out. It was working not too long ago, so not sure what happened. The hamburger menu (on mobile) also stop working. Seems like a joint issue, but not sure?
HTML for 3 Dropdown Tables:
<div
class="accordion mt-5"
id="scenarios"
role="tablist"
aria-multiselectable="true"
>
<div class="panel-primary mb-3">
<div class="text-white" role="tab" id="studentHeading">
<h4>
<button
class="w-100 p-4 btn-primary text-center"
data-toggle="collapse"
data-parent="#scenarios"
data-target="#student"
aria-expanded="false"
aria-controls="student"
>
<div class="d-flex justify-content-between">
<div class="col-10 text-center text-sm-left">
<span>100% Student Loan Contribution</span>
</div>
<div class="col-2 h-100 my-auto">
<span
class="symbol rounded-circle d-block ml-auto"
></span>
</div>
</div>
</button>
</h4>
</div>
<div
id="student"
class="rounded panel-collapse collapse"
role="tabpanel"
aria-labelledby="studentHeading"
>
<h5 class="text-center pt-5 mx-3">
Employer contributes <strong>$0</strong> to employee retirement
plan and <strong>$3,000</strong> to student loans annually.
</h5>
<div class="mr-3">
<table
class="table justify-content-center text-center text-white round-table mt-5 mb-2 table-responsive-sm"
>
<caption>
<span class="sr-only"
>100% Student Loan Contribution</span
>
</caption>
<thead>
<tr>
<td class="pr-4"></td>
<th scope="col">Retirement Plan</th>
<th scope="col">Student Loan</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row" class="pr-4">
Employee Contributes
</th>
<td>0%</td>
<td>5% ($250/month)</td>
</tr>
<tr>
<th scope="row" class="pr-4">Employer Match</th>
<td>0%</td>
<td>5% ($250/month)</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="panel-secondary mb-3">
<div class="text-white" role="tab" id="retirementHeading">
<h4>
<button
class="w-100 p-4 btn-secondary text-center"
data-toggle="collapse"
data-parent="#scenarios"
data-target="#retirement"
aria-expanded="false"
aria-controls="retirement"
>
<div class="d-flex justify-content-between">
<div class="col-10 text-center text-sm-left">
<span>100% Retirement Plan Contribution</span>
</div>
<div class="col-2 h-100 my-auto">
<span
class="symbol rounded-circle d-block ml-auto"
></span>
</div>
</div>
</button>
</h4>
</div>
<div
id="retirement"
class="panel-collapse collapse rounded"
role="tabpanel"
aria-labelledby="retirementHeading"
>
<h5 class="text-center pt-5 mx-3">
Employer contributes <strong>$0</strong> to employee student
loans and <strong>$3,000</strong> to retirement plan annually.
</h5>
<div class="mr-3">
<table
class="table w-100 justify-content-center text-center text-white round-table mt-5 mb-2 table-responsive-sm"
>
<caption>
<span class="sr-only"
>100% Retirement Plan Contribution</span
>
</caption>
<thead>
<tr>
<td class="pr-4"></td>
<th scope="col">Retirement Plan</th>
<th scope="col">Student Loan</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row" class="pr-4">
Employee Contributes
</th>
<td>5% ($250/month)</td>
<td>0%</td>
</tr>
<tr>
<th scope="row" class="pr-4">Employer Match</th>
<td>5% ($250/month)</td>
<td>0%</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="panel-support mb-3">
<div class="text-white" role="tab" id="splitHeading">
<h4>
<button
class="w-100 p-4 btn-support text-center"
data-toggle="collapse"
data-parent="#scenarios"
data-target="#split"
aria-expanded="false"
aria-controls="split"
>
<div class="d-flex justify-content-between">
<div class="col-10 text-center text-sm-left">
<span>Retirement Plan/Student Loan Split</span>
</div>
<div class="col-2 h-100 my-auto">
<span
class="symbol rounded-circle d-block ml-auto"
></span>
</div>
</div>
</button>
</h4>
</div>
<div
id="split"
class="panel-collapse collapse rounded"
role="tabpanel"
aria-labelledby="splitHeading"
>
<h5 class="text-center pt-5 mx-3">
Employer contributes <strong>$1,800</strong> to employee
retirement plan and <strong>$1,200</strong> to student loans
annually. Retirement plan contributions must be matched before
student loan contributions can be applied.
</h5>
<div class="mr-3">
<table
class="table w-100 justify-content-center text-center text-white round-table mt-5 mb-2 table-responsive-sm"
>
<caption>
<span class="sr-only"
>Retirement Plan/Student Loan Split</span
>
</caption>
<thead>
<tr>
<td class="pr-4"></td>
<th scope="col">Retirement Plan</th>
<th scope="col">Student Loan</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row" class="pr-4">
Employee Contributes
</th>
<td>3% ($150/month)</td>
<td>5% ($250/month)</td>
</tr>
<tr>
<th scope="row" class="pr-4">Employer Match</th>
<td>3% ($150/month)</td>
<td>2% ($100/month)</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>