What is the best way to align text alongside icons using ng-bootstrap in Angular 8?

I have a set of four icons positioned next to each other, but I want them to be evenly spaced apart. I tried using the justify-content-between class, but it didn't work. How can I achieve this?

I'm creating a Progressive Web App (PWA) for mobile phones.

  • Below, I will provide the code and an image illustrating how I want the layout to look. I am utilizing Bootstrap and Angular Material for this project.

Here is the code snippet with the icons:

<div class="main flex down fixed-bottom" >
<mat-toolbar class="colour">
    <mat-toolbar-row>

    <div class="row justify-content-between">
        <div class="icons"> 
            <button mat-icon-button class="icons col-xs-3" >
                <mat-icon>home</mat-icon>
            </button>
            <button mat-icon-button class="icons col-xs-3" >
                <mat-icon>email</mat-icon>
            </button>
            <button mat-icon-button  class="icons col-xs-3">
                <mat-icon>add_comment</mat-icon>
            </button>
            <button mat-icon-button class="icons col-xs-3" >
                <mat-icon>title</mat-icon>
            </button>
        </div>
    </div>
    </mat-toolbar-row>
</mat-toolbar>
</div>

This is the current appearance:

https://i.stack.imgur.com/YHbaZ.png

This is the desired layout: https://i.stack.imgur.com/CkHpP.png

Answer №1

Follow this structure for your div.

<div class="main flex down fixed-bottom" >
<mat-toolbar class="colour">
    <mat-toolbar-row>

        <div class=" icons row justify-content-between"> 
            <button mat-icon-button class="icons col-xs-3" >
                <mat-icon>home</mat-icon>
            </button>
            <button mat-icon-button class="icons col-xs-3" >
                <mat-icon>email</mat-icon>
            </button>
            <button mat-icon-button  class="icons col-xs-3">
                <mat-icon>add_comment</mat-icon>
            </button>
            <button mat-icon-button class="icons col-xs-3" >
                <mat-icon>title</mat-icon>
            </button>
        </div>

    </mat-toolbar-row>
</mat-toolbar>
</div>

Answer №2

This is my solution


<div class="main flex down fixed-bottom" >
    <mat-toolbar class="colour">
        <mat-toolbar-row>
            <div class="container icons">
                <div class=" row justify-content-between">
                    <button mat-icon-button class=" col-xs-3">
                        <mat-icon>home</mat-icon>
                    </button>
                    <button mat-icon-button class=" col-xs-3">
                        <mat-icon>email</mat-icon>
                    </button>
                    <button mat-icon-button class=" col-xs-3">
                        <mat-icon>add_comment</mat-icon>
                    </button>
                    <button mat-icon-button class=" col-xs-3">
                        <mat-icon>title</mat-icon>
                    </button>
                </div>
            </div>
        </mat-toolbar-row>
    </mat-toolbar>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular formArray option buttons

I am currently working on incorporating a radio button group into a FormArray, but I'm encountering an issue where selecting a value changes the value for every member of the FormArray. It seems to be related to the formControlName, however, I am unsu ...

Conceal the slider image without removing it

Is there a way to hide the slider background image on mobile screens? @media screen and (max-width: 800px){ .home #mainSliderWrapper { background-image: none; } .stlye { background-image: none; } .img--holder { background-image:none; } } I tr ...

How do I ensure my Instrument Cards maintain dynamic sizing while also defining a minimum card size with React-Bootstrap?

Let's talk about my current situation This is how my cards are currently set up: Looks good, right? However, when you adjust the screen size, it looks like this: Not so great, especially in today's responsive design standards. I want the card ...

Issue with displaying rows in Bootstrap grid

Is there a way to display images in a row for my portfolio instead of a column? I've checked my code but can't seem to figure out what's causing them to display vertically. Any assistance would be appreciated. Below is the code snippet: < ...

Is it possible for Bootstrap to hide a grid column on extra small screens by setting its column width to zero?

Is there a specific Bootstrap class that allows me to hide a grid column for certain screen sizes without using media queries and the "display:none" style? ...

Combining the power of Angular CLI with Squarespace

Has anyone managed to successfully integrate Angular CLI into a Squarespace website? I've been trying to find a solution to this issue but haven't had any luck. While it's possible to add custom scripts or use CDNs on Squarespace, deploying ...

Strategies for eliminating nested subscriptions in the search for names

I need assistance with refactoring a component I created to search for GitHub users by login. The current implementation contains nested subscribe blocks, and I would like to rewrite it using rxjs operators without nesting them. You can find the live exam ...

Creating distance between two text boxes in bootstrap is easy with the use of margins. By

I am looking to create a small white space between two text boxes. <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet" /> <div class="row col-lg-12 col-sm-12"> <div class ...

"Move a div towards the mouse's location by animating it with JavaScript when

I've been working on making the ball element move and shrink towards the goals upon mouse click. I successfully created a function that captures the mouse click coordinates in the goals, but I'm facing challenges with the ball animation. I consi ...

Issues with the Angular Global Messaging service and how to tackle them

I am currently developing a web application using Angular 7 and I have implemented an API interceptor to show alerts when errors occur. Everything was working fine until I added a messaging service and messaging component. When I tried pushing the error me ...

"(PHP)WordPress produces a dynamic menu that adapts to different screen sizes

I recently created a menu on my WordPress site [ and I'm facing an issue with making it display vertically in a responsive way. The code in header.php is as follows: <!-- header --> <header> <div class="overNavPanel"> ...

Issue encountered with Angular 13 and Twilio Sync: The variable name is not recognized as a constructor, resulting in

After upgrading to angular 13, I encountered a problem that was not present when using angular 10. In my TwilioSyncService, the require statement is included in the constructor because it is an Injectable service requirement. The code snippet shows how t ...

Implement a floating div below an accordion element on the page

As depicted in the image, there is a "Quick Tips" div located below the accordion. Let's assume the outermost div is named id="TipsDiv". The goal is to ensure that this div remains below the accordion as the user scrolls down, never going above positi ...

Increasing box width in Django

I'm currently working on a website using Django all-auth for authentication. Everything is functioning perfectly, but I'm wondering if there's a way to increase the size of the username and password input boxes using HTML. Below is the code ...

Exploring the power of flow.js within an Angular 2 Typescript project

I am trying to incorporate flowjs or ng-flow into my Angular 2 application. After installing the flowjs typings using npm install --save-dev @types/flowjs from However, upon importing it into my component with import { Flow } from 'flowjs';, ...

Challenges in implementing Angular's guard correctly

I have a simple task that I'm struggling with - creating a guard to protect a route from all users except those with an "admin" role. To check this, I send a request to my API server with the user's API token. The server then responds with eithe ...

Make the text in the SCSS file placeholder bold

Within my Angular front end application, there is a form containing a textarea: <mat-form-field class="full-width"> <textarea class="left-aligned" formcontrolname="x1" matInput placeholder="some text"/> </mat-form-field> In the co ...

Aligning images in center of list

I'm in need of some CSS expertise to assist with this layout. Here is the current structure: <div class="movieList"> <div class="image" selected = true> <img class="poster" src="image1" selected = true/> </div> <d ...

An informative step-by-step approach to constructing Angular applications utilizing npm and TypeScript

When I first encountered Angular2, I was introduced to TypeScript, npm, and more for the very first time. I was amazed by their power, but I know I've only scratched the surface. While I can navigate through the "development mode," my ultimate goal i ...

iterating over a nested map within a map in an Angular application

I wrote a Java service that returns an observable map<k, map<k,v>> and I'm currently struggling to iterate through the outer map using foreach loop. [...] .then( (response: Package) => { response.activityMap.forEach((key: s ...