I have a small form designed but it is misaligned. I am trying to align properly but not sure why its becoming so messy. The problem with the design is when i click on plus button the below things happen:
The blue color content right side gets increased and in turn it adds extra space vertically which is messy. I want the blue color content to be at fixed height.
The minus button needs to be placed properly beside its corresponding line.
Also the plus button should be aligned properly.
Can anyone help me out on this.
The below is my code:
<div class="row">
<div class="col-md-8">
<mat-dialog-content class="mat-typography">
<section *ngFor="let address of endpointsBulk; let i = index;">
<div class="row">
<div>
<!-- <h4>Endpoint {{i + 1}}</h4> -->
</div>
<div class="text-right" *ngIf="endpointsBulk.length > minEndpoints">
<button mat-button color="danger" (click)="removeEndpointForm(i)">
<i class="fa fa-minus" aria-hidden="true"></i>
</button>
</div>
</div>
<div class="row">
<div>
<mat-form-field class="example-full-width">
<mat-label>Choose Method</mat-label>
<mat-select [(ngModel)]="address.method">
<mat-option value="post">POST</mat-option>
<mat-option value="get">GET</mat-option>
<mat-option value="put">PUT</mat-option>
<mat-option value="delete">DELETE</mat-option>
</mat-select>
</mat-form-field>
</div>
<div>
<mat-form-field class="example-full-width">
<input name="search" id="search" [(ngModel)]="address.endpoint" matInput type="search"
placeholder="Endpoint">
</mat-form-field>
</div>
</div>
</section>
<div class="text-right" *ngIf="endpointsBulk.length < maxEndpoints">
<button mat-button color="primary" (click)="addEndpoinForm();">
<i class="fa fa-plus" aria-hidden="true"></i>
</button>
</div>
</mat-dialog-content>
</div>
<div class="col-md-4 callout callout-info no-margin">
<li>Format: post:/api/v1/addAccount/id
<br> Usage :
<ul>
<li>post:/api/v1/addAccount/id</li>
<li>get:/api/v1/getAccount/id</li>
<li>put:/api/v1/updateAccount/id</li>
<li>delete:/api/v1/deleteAccount/id</li>
</ul>
</li>
</div>
</div>
<mat-dialog-actions class="pull-right" align='end'>
<button mat-raised-button class="nav-btn text-primary" type="submit" [disabled]="checkFormValidity()"
(click)="saveEndPoint()">Save</button>
<button mat-raised-button class="nav-btn text-primary" (click)="dialogRef.close()">Cancel</button>
</mat-dialog-actions>
The design is something like below:
You can limit the height of the right side with height: fit-content;
You seem to be putting each element (minus, form) inside a separate row, try using columns instead if you want them next to each other
The alignment of plus is just a matter of putting it in a correct container, please specify what is "aligned properly"
Related
I want to change the button position in my html code but I got a problem in the j like in the photo below ! I want to put the button in the footer of the modal !
the Output (button in the bottom) :
here is it my code:
<div class="modal-header" >
<h6 class="modal-title" id="modal-basic-title">Notes</h6>
<button type="button" class="close" aria-label="Close" (click)="closemodal()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" style="width:500px ; height:600px; overflow-y: auto" >
<mat-accordion >
<mat-expansion-panel *ngFor="let i of listCategorie" class="parentPanel" >
<mat-expansion-panel-header class="parentPanel_header" (click)="getSouCategories(i.id)" >
<mat-panel-title > {{i.libelle}} {{i.id}}
<span class="badge badge-light " style="position:absolute; right:6em"> {{listCategorie.length}} </span>
</mat-panel-title>
</mat-expansion-panel-header>
<mat-accordion multi>
<mat-expansion-panel style="background-color: #EEDFF5;" class="childPanel childPanelCount" [expanded]="true" hideToggle disabled>
<div class="d-flex mt-2">
<div class="p-2"><p> Nombre des sous catégories </p></div>
<div class="ml-auto p-2">
<span class="badge badge-secondary "> {{listSousCategorie.length}} </span>
</div>
</div>
</mat-expansion-panel>
<ng-container>
<mat-expansion-panel class="childPanel" [expanded]="true" hideToggle disabled style=" background:#F2EDFF;"
*ngFor="let j of listSousCategorie; ">
<div class="childPanel_body2 mat-badge-large" fxLayout="row" fxFlex fxLayoutAlign="start center">
<div style="padding-left:1em" fxFlex="grow">{{j.libelle}} {{j.id}}</div>
<mat-form-field style="width:50px" appearance="standard">
<form>
<mat-label>Note</mat-label>
<input type="text" matInput name="Note" [(ngModel)]="j.Note_Condidat">
<button type="button" (click)="onSubmit(j)"> ok</button>
</form>
</mat-form-field>
</div>
</mat-expansion-panel>
</ng-container>
</mat-accordion>
</mat-expansion-panel>
</mat-accordion>
</div>
Ts File:
onSubmit(sous) {
this.LExamenSousCategorieService.updateSouCategorie(sous).then(res => {
})
}
i think you should give parent element of button "position: relative" and make your button positioning with "position: absolute; (and margin,padding vs...)"
I want add two div's in a single div one is to right and other is to left.
<html>
<div>
<div><button class="mat-button menu-button">
<mat-icon color="primary"> remove </mat-icon>
Add Site
</button>
</div>
<div *ngIf="showButtons">
<button>edit</button>
<button >Save</button>
</div>
</div>
</html>
use float css property to align div left and right
.left {
float: left;
}
.right {
float: right;
}
<div>
<div class='left'><button class="mat-button menu-button">
<mat-icon color="primary"> remove </mat-icon>
Add Site
</button>
</div>
<div *ngIf="showButtons" class='right'>
<button>edit</button>
<button>Save</button>
</div>
</div>
you can use ng-container instead of div for button one is to right and other is to left.
<div>
<button class="mat-button menu-button">
<mat-icon color="primary"> remove </mat-icon>
Add Site
</button>
<ng-container *ngIf="showButtons">
<button>edit</button>
<button>Save</button>
</ng-container>
</div>
You could set the display to flex, the default direction is row :
<div style="display:flex;">
<div><button class="mat-button menu-button">
<mat-icon color="primary"> remove </mat-icon>
Add Site
</button>
</div>
<div *ngIf="showButtons">
<button>edit</button>
<button >Save</button>
</div>
</div>
.firstCol{
float : left;
}
<html>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="firstCol"><button class="mat-button menu-button">
<mat-icon color="primary"> remove </mat-icon>
Add Site
</button>
</div>
<div *ngIf="showButtons">
<button>edit</button>
<button >Save</button>
</div>
</div>
</div>
</div>
</html>
You did it well, just add a class name or an Id on the div and you can do what you want with CSS with for exemple the float property.
Is there any other short and fast way to align to your <div> or <input> or anything? Suppose I want to make a bootstrap modal:
<!-- Trigger the modal with a button -->
<li>
<button type="button" class="fa fa-search fa-2x search-icon" data-toggle="modal" data-target="#search"></button>
</li>
<!-- Modal -->
<div id="search" class="modal fade" role="dialog">
<div class="modal-dialog search">
<!-- Modal content -->
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal">×</button>
<input class="searchArea" type="search" placeholder="Search Here">
</div>
</div>
</div>
If I make a modal and want to add <input type="search"> in the modal, and without any CSS positioning (top left right bottom), can I put the INPUT SEARCH box in the center of the page?
Use auto margins for left and right. For example:
.searchArea {
margin-left: auto;
margin-right: auto;
/* or, for example, margin: 20px auto; */
}
Seems like Bootstrap's text-center class does the job:
<div class="text-center">
<button type="button" class="btn" data-dismiss="modal">Close</button>
<input class="searchArea" type="search" placeholder="Search Here">
</div>
Fiddle
you could use
<center></center>
... but is deprecated
another way is using class of bootstrap
<div class="row">
<div class="col-md-2 col-md-offset-5"></div>
</div>
thanks to TylerH in her answer... https://stackoverflow.com/a/18153551/4102927
but this is css in background
I want to make the Submit button's length same as the input field above it.
<div class="row">
<div class="input-field col s12">
<input id="speciality" type="text" class="validate">
<label for="speciality">Speciality</label>
</div>
</div>
<div class="row">
<button class="btn waves-effect waves-light" type="submit" name="action">Search
<i class="material-icons right">search</i>
</button>
</div>
If your column which you have your input field in is limited to a certain width (in the way how the Bootstrap columns work), you can put the .btn inside a column as well.
After that, you can use the following CSS to make the width equal to the input field:
.col.s12 > .btn {
width: 100%;
}
Of course if the button as an element does not bend to this CSS-rule, you can use <a class="btn"> instead.
Surround the button with a div with col s12 classes and add btn-block to the button:
<div class="row">
<div class="col s12">
<button class="btn btn-block waves-effect waves-light" type="submit" name="action">Search
<i class="material-icons">search</i>
</button>
</div>
</div>
And add the following CSS:
.btn-block {
width: 100%;
}
My html code looks like this (using Bootstrap):
<div class="row">
<div class="col-md-4 col-md-offset-1" style="width: 37.5%">
<span class="dualselect">
<select class="form-control input-default select-inline" style="width: 100%" multiple="multiple">
</select>
</span>
</div>
<div class="col-md-1" align="center">
<div class="dualselect">
<div class="ds_arrow">
<button class="btn btn-inverse">
<i class="fa fa-chevron-right"></i>
</button>
<br/>
<button class="btn btn-inverse">
<i class="fa fa-chevron-left"></i>
</button>
</div>
</div>
</div>
<div class="col-md-4" style="width: 37.5%">
<span class="dualselect">
<select class="form-control input-default select-inline" style="width: 100%" multiple="multiple">
</select>
</span>
</div>
</div>
This works perfectly fine in IE or Firefox. In Chrome the buttons with arrows are not perfectly aligned:
The problem seems to be with align="center". When removed, the buttons are aligned in all the browsers but I want them centered. How do I do that properly?
I'm a little surprised all browsers aren't showing the same result that Chrome does. The problem is the white space in your code. Remove it around the buttons code so it looks like this:
<button class="btn btn-inverse">
<i class="fa fa-chevron-right"></i>
</button><br/><button class="btn btn-inverse">
<i class="fa fa-chevron-left"></i>
</button>
bootply example
An alternative would be to put each <button> in it's own separate <div>, and then eliminate the <br/>, thereby allowing you to keep whitespace for code aesthetics.
You can also go other way:
Make your "row" class with attribute "position: relative", then in your "col-md-1" class set attribute "position:absolute, left: 50%, margin-left: -yourwidth in px" and you will get centered your "col-md-1".
But keep in mind that you will need also to edit your other "col-md-4"