How to display buttons in a row in angular - html

For some reason when I added the third button, the buttons started showing in a column manner.
html:
<div class="creator-button-container" *ngIf="isCurrentUserTheChannelCreator">
<div *ngIf="isChannelEditable">
<button mat-raised-button color="accent" type="button" (click)="openDialog()">Add field </button>
<div *ngIf="isChannelReadyForBids">
<button mat-raised-button color="accent" type="button" (click)="setState('in progress')">Open the channel for
bidding
</button>
</div>
<button mat-raised-button color="accent" type="submit">Save Channel</button>
</div>
<div *ngIf="form.value.state=='in progress'&&userId === channel.creator">
<button mat-raised-button color="accent" type="button" (click)="setState('new')">Edit channel </button>
</div>
</div>
css:
.creator-button-container{
background-color: red;
display: inline-block;
flex-direction: row;
}
I though the 'display: inline-block' would work but its not working
I looked at this solution but i didnt understand it: Angular - display buttons in rows of two
its weird because as soon as i added the third button, the buttons started being displayed as a column

Add buttons in div tag because div is block level element.
Something like this:
<div>
<div><button class="btn">B1</button></div>
<div><button class="btn">B2</button></div>
<div><button class="btn">B3</button></div>
</div>

Related

Set position in Bootstrap without affecting responsiveness

I am a noob in web design. I have just begun experimenting with Bootstrap. I want to add two buttons
like this,
but, I am getting this on mobile devices
with this code:
<button style = "position:absolute; left:38%; top:50%; z-index=0" type="button" class="btn btn-primary btn-lg">Large button</button>
<button style = "position:absolute; left:53%; top:50%; z-index:0" type="button" class="btn btn-primary btn-lg">Large button</button>
I know I shouldn't add position attributes as they make responsiveness ineffective, but not using them places the buttons like this.
So how should I go about it? How can I specify position without affecting responsiveness?
Thank You!
Thanks to the comment by #zgood, I have it fixed with this:
<div style="width:100vw; height: 100vh; display:flex; align-items: center; justify-content:center">
<button style="margin:20px" type="button" class="btn btn-primary btn-lg">Large button</button>
<button style="margin:20px" type="button" class="btn btn-primary btn-lg">Large button</button>
</div>

Angular mat-menu margin

I have a problem with the mat-menu, I have looked all over the place but nothing is working. I'm trying to add a margin-top but this one is never supported.
navbar-no-mobile.component.html
<div class="pull-right">
<button class="btn-language" mat-icon-button [matMenuTriggerFor]="menu">
<mat-icon [ngClass]="{'flag-francais': isFrench, 'flag-english': !isFrench}"></mat-icon>
<a lang="{{language}}">{{language}}
<fa-icon class="chevron_white" aria-hidden="true" [icon]="faChevronDown"></fa-icon>
</a>
</button>
<mat-menu class="flag-menu" #menu="matMenu">
<button mat-menu-item (click)="switchToEnglish()">
<mat-icon class="flag-english"></mat-icon>
<span lang="english">English</span>
</button>
<button mat-menu-item (click)="switchToFrench()">
<mat-icon class="flag-francais"></mat-icon>
<span lang="français">Français</span>
</button>
</mat-menu>
</div>
navbar-no-mobile.component.scss
/deep/ .cdk-overlay-container .flag-menu {
margin-top: 4em;
}
I have also tried placing the css in the overall css (styles.scss) and inverting .flag-menu with .cdk-overlay-container or use ::ng-deep instead of /deep/ but it also doesn't work.
This work for me:
::ng-deep .cdk-overlay-container .flag-menu {
margin-top: 3rem;
}
check the stackblitz: https://stackblitz.com/edit/mat-menu-xruuog
If it's not working for you please create stackblitz for your code.

how to align some 3 buttons on the right side of div

I have a div and want to place some buttons eg; 3 buttons to the right side of the div. Can anyone help how to achieve this?
I am using Primeng with Angular2
<div class="ui-g-12" style="border:solid 1px red;">
<button pButton type="button" class="ui-button-info" label="BUTTON1"></button>
<button pButton type="button" class="ui-button-danger" label="BUTTON2"></button>
</div>
Thanks
Here is my current output. I need the button to be placed on the right side
Try this :
<div class="ui-g-12" style="border:solid 1px red; text-align:right">
<button pButton type="button" class="ui-button-info" label="BUTTON1"></button>
<button pButton type="button" class="ui-button-danger" label="BUTTON2"></button>
</div>
There is nothing link to Angular2
You just need to add css property text-align: right
For more get in touch here
https://www.w3schools.com/cssref/pr_text_text-align.asp
Add text-align: right; to the parent of your buttons:
<div class="ui-g-12" style="text-align: right; border:solid 1px red;">
<button pButton type="button" class="ui-button-info" label="BUTTON1"></button>
<button pButton type="button" class="ui-button-danger" label="BUTTON2"></button>
</div>

How to align three icons to the right of the page headline

I have the current situation:
Relevant code:
<md-toolbar color="primary" class="main-toolbar">
<div fx-layout="row" fx-flex fx-layout-align="space-between">
<span class="page-headline">
<img class="logo" src="./logo.png"/>club
</span>
<button md-icon-button class="main_menu_button1" (click)="dinnerClicked()">
<md-icon>local_pizza</md-icon>
</button>
<button md-icon-button class="main_menu_button2" (click)="notificationsClicked()">
<md-icon>notifications</md-icon>
</button>
<button md-icon-button class="main_menu_button3" (click)="eventsClicked()">
<md-icon>event_note</md-icon>
</button>
</div>
</md-toolbar>
I just want the 3 icons to be adjacent closely to each other and align to the right. If I change fx-layout-align to fx-layout-align-xs, I get almost what I want:
But to the left instead of to the right...
I have tried many CSS configurations but none worked for me, is there any easy way to acheive this? Many thanks.
If you are using this plugin: https://github.com/angular/flex-layout#api-overview
i suggest:
<md-toolbar color="primary" class="main-toolbar">
<div fx-layout="row" fx-flex fx-layout-align="end" >
...
</div>
</md-toolbar>
Just add below code in your css:
<style>
.main_menu_button1,.main_menu_button2,.main_menu_button3
{
float:right;
}
</style>

Using a button to move to a certain ID on a page

So I'm making a website (suprise, suprise) and I have a button on the top of the page, and when I click it, it does nothing. I am wondering how to fix it.
The button
<button class="Learn-Link" href="#VideoSlide">Learn How
<div class="Learn-Triangle"></div>
</button>
And the part I want to travel to
<div class="Slide" id="VideoSlide">
<!--More code here, but not relevant-->
</div>
button doesn't have an href attribute you need to add an a tag inside your button
#VideoSlide{
position: relative;
top:1000px;
height: 100px;
background: pink
}
<button class="Learn-Link" >Learn How
<div class="Learn-Triangle"></div>
</button>
<div class="Slide" id="VideoSlide">
<!--More code here, but not relevant-->
</div>
You can trigger button by using javascript
Eg:-
<button type="button" onclick="alert('Hello world!')">Click Me!</button>