Bootstrap : Vertically center row in container [duplicate] - html

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>

Related

Remove a space white on bootstrap

In a code bootstrap, I wanted to go up the button towards horizontal bar.
enter image description here
<div class="separator-breadcrumb border-top"></div>
<div class="row">
<div class="col-12">
<div class="card mb-4">
<div class="card-body">
<div class="card-title d-flex align-items-center justify-content-end">
<button (click)="showPreviousYear()" *ngIf="showPreviousYearButton()" class="btn btn-primary ">
< {{previousYear}}
</button>
<button (click)="showNextYear()" *ngIf="showNextYearButton()" class="btn btn-primary mx-1">
{{nextYear}} >
</button>
</div>
<div class="table-responsive" *ngIf="lines.length > 0">
<table class="table table-striped">
<thead>
<tr>
<th scope="col" style="width: 25%;">{{'4391' | t}}</th>
<th scope="col" style="width: 25%; text-align: right;">{{'4392' | t}}</th>
<th scope="col" style="width: 25%; text-align: right;">{{'4393' | t}}</th>
<th scope="col" style="width: 25%; text-align: right;">{{'4394' | t}}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let line of lines; let i = index">
<th style="width: 25%;">
{{line.LIBELLE}}
</th>
<td style="width: 25%; text-align: right;">
{{line.TAUX | number:'1.2-2' | mynamformatnum}} %
</td>
<td style="width: 25%; text-align: right;">
{{line.BASE | number:'1.2-2' | mynamformatnum}} EUR
</td>
<td style="width: 25%; text-align: right;">
{{line.MONTANT | number:'1.2-2' | mynamformatnum}} EUR
</td>
</tr>
</tbody>
</table>
</div>
<h5 *ngIf="lines.length == 0">
{{'4395' | t }}
</h5>
</div>
</div>
</div>
</div>
I added a class btn-top in css
<button (click)="showPreviousYear()" *ngIf="showPreviousYearButton()" class="btn btn-primary btn-top">
And
.btn-top {
position: relative;
top: -100px;
}
Now, I will want to remove the space white of the table, I don't find the class bootstrap to apply that?
enter image description here
For alignment of button, Along with the heading, give the buttons, separate them using col-6
for example
<div class="row">
<div class="col-6">
<h3 class="title">Taxes</h3>
</div>
<div class="col-6">
button
</div>
</div>
And for removing space, as you are using "bootstrap cards" which define padding which create white space so remove that by adding p-0
For example
<div class="card-header p-0">
<div class="card-body p-0">

How to align a checkbox with specified column in table HTML

<div class="col-md-12" style="padding: 10px">
<div class="card m-b-30">
<div class="card-header container-fluid" ">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-12 table-responsive">
<div id="order-listing_wrapper" class="dataTables_wrapper container-fluid dt-bootstrap4 no-footer">
<div class="row">
<div class="col-md-12">
<table id="order-listing" class="table dataTable no-footer table-striped" style="border-bottom:1pt solid black" role="grid" aria-describedby="order-listing_info">
<thead>
<tr role="row">
<th width="70%"><b>Name</b></th>
<th><b>Active</b></th>
<th><b>Select</b></th>
<th><b>Delete</b></th>
</tr>
</thead>
<tbody>
#*#foreach (var item in Model)
{*#
<tr>
<td>
<div class="input-group">
<input type="text" class="form-control" placeholder="Search here" style="width: 450px; height: 40px">
<div class="input-group-append">
<button class="btn btn-secondary" type="button">
<i class="dripicons-search"></i>
</button>
</div>
</div>
</td>
<td>
<input type="checkbox" name="checkbox2">
</td>
</tr>
<tr>
<td>Test New</td>
<td><input class="form-check-input" type="checkbox" id="gridCheck"></td>
<td><button type="button" class="btn btn-icons btn-inverse-secondary" id="data-editbtn-id"><div><i class="icon-pencil"></i></div></button></td>
<td><button type="button" class="btn btn-icons btn-inverse-secondary" id="data-delete-id"><div><i class="dripicons-trash"></i></div></button></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I tried aligning this checkbox with the Active column but my code doesn't align it with the specified column
whats wrong with my code?
some online HTML generates output the correct code with same code but when i edit it, the aligned doesn't work properly
I have attached my code above can anyone help me im using html and css for this.
Please give the below CSS, the input element is taking CSS of margin-left.
.form-check-input{
margin:0 !important;
}
And also give this CSS
.table td, .table th{
vertical-align: middle;
}

Creating advanced layout - Flexbox or Table

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/

Dropdown Boxes Not Responding

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>

unable to fix the issue when used bootstrap classes

I see two issues with my code. Header is not getting fixed and second issue is word wrap is not applicable for the headers/rows.
I have used bootstrap classes, but still facing issues. I want to fix the table header and only rows should be scrollable and if the text is long it should automatically word wrap. I have multiple columns in my application(approximately 15 columns).Please advice.
To view the sample code click here.
Sample html code:
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body" id="modal-body">
<table id="myTable" class="table table-fixedheader table-bordered table-striped">
<thead>
<tr class="row">
<th class="col-md-3">Header1</th>
<th class="col-md-4">Header2Header2Header2Header2</th>
<th class="col-md-3">Header3</th>
<th class="col-md-4">Header4</th>
</tr>
</thead>
<tbody>
<tr class="row">
<td class="col-md-3">111111111111111111111111111111111111111111111111111111111111111111111</td>
<td class="col-md-4">33333</td>
<td class="col-md-3">1111</td>
<td class="col-md-4">5443545435354543</td>
</tr>
<tr class="row">
<td class="col-md-3">1111</td>
<td class="col-md-4">33333</td>
<td class="col-md-3">1111</td>
<td class="col-md-4">5437665</td>
</tr>
<tr class="row">
<td class="col-md-3">1111</td>
<td class="col-md-4">33333</td>
<td class="col-md-3">1111</td>
<td class="col-md-4">5435435443</td>
</tr>
<tr class="row">
<td class="col-md-3">1111</td>
<td class="col-md-4">33333</td>
<td class="col-md-3">1111</td>
<td class="col-md-4">68678454</td>
</tr>
<tr class="row">
<td class="col-md-3">1111</td>
<td class="col-md-4">786876</td>
<td class="col-md-3">8787876</td>
<td class="col-md-4">6765767</td>
</tr>
<tr class="row">
<td class="col-md-3">7656765</td>
<td class="col-md-4">656456</td>
<td class="col-md-3">116611</td>
<td class="col-md-4">43434</td>
</tr>
<tr class="row">
<td class="col-md-3">43243432434324342</td>
<td class="col-md-4">33344343233</td>
<td class="col-md-3">1111</td>
<td class="col-md-4">4343</td>
</tr>
<tr class="row">
<td class="col-md-3">1111</td>
<td class="col-md-4">432434343243243</td>
<td class="col-md-3">1111</td>
<td class="col-md-4">432443</td>
</tr>
<tr class="row">
<td class="col-md-3">1111</td>
<td class="col-md-4">333333</td>
<td class="col-md-3">111312312123121</td>
<td class="col-md-4">32112</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
You could try a non table approach. If your ok with having set widths on the columns with content wrapping in the cells. Here's an example https://codepen.io/flurrd/pen/jmMNxK?editors=1100
Note: Class names are terrible in this example. I'd BEM it up for proper usage.
.table-body {
max-height: 200px;
overflow-y:auto;
}
.t-row {
display: flex;
border-bottom: 1px solid grey;
}
.t-row:nth-child(even){
background: #e3e3e3;
}
.col {
word-wrap: break-word;
flex: 1 0 30%;
max-width: 33.3333%;
}
.cell {
padding: 8px;
}
<div class="table-wrap">
<div class="t-row t-header">
<div class="col">
<div class="cell">
Header 1
</div>
</div>
<div class="col">
<div class="cell">
Header 1
</div>
</div>
<div class="col">
<div class="cell">
Header 1
</div>
</div>
</div>
<div class="table-body">
<div class="t-row">
<div class="col">
<div class="cell">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</div>
</div>
<div class="col">
<div class="cell">
1111
</div>
</div>
<div class="col">
<div class="cell">
11111111
</div>
</div>
</div>
</div>
</div>