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

Updating padding through local storage does not function as intended

I recently added two buttons to my website for adjusting the padding. While they are functional, I find myself manually setting the padding for nav, main, and footer in the CSS. Here is the snippet of the code: main { padding: 20px 25%; } footer { ...

Using an aria-label attribute on an <option> tag within a dropdown menu may result in a DAP violation

Currently, I am conducting accessibility testing for an Angular project at my workplace. Our team relies on the JAWS screen reader and a helpful plugin that detects UI issues and highlights them as violations. Unfortunately, I've come across an issue ...

Having difficulty creating a shadow beneath a canvas displaying Vega charts

I'm looking to create a floating effect for my chart by adding shadows to the canvas element that holds it. Despite trying various methods, I can't seem to get the shadow effect to work. Here is the code snippet I have for adding shadows: <sc ...

Tips for confining a float within a div with fluctuating space

I have a scenario where I have multiple divs ('group') containing text, and there is a floated div ('toggle') in the bottom corner. The current code works well if the text length in 'group' is consistent, but the position of t ...

Creating line breaks for ToolTip titles in Material-UI can be achieved by using the appropriate syntax and

I am currently working with the ToolTip component and I have a query regarding displaying two lines for the title text - one line for each language rather than having them displayed on a single line. Is it possible to achieve this and how can I style the c ...

Dividing the webpage background into separate sections to showcase a variety of colors, patterns, and more

I'm in the process of dividing the background on my website into distinct areas. My goal is to have the patterned area extend both horizontally and vertically on either side until it reaches the edge of the visible webpage. Figuring out how to achiev ...

Unable to access or modify properties within a function passed as an argument

deleteDialog(item, func: Function) { this.dialogService .open(ConfirmDialogComponent, { context: { title:"Are you sure?", cancelClss: "info", confirmClss: "danger", }, ...

Issue NG0203 encountered during material import attempt

I've been encountering an issue with importing material. Despite using code similar to the examples on material.angular.io, I keep running into the ""inject() must be called from an injection context..." error. My goal is to create a simple table ...

Is there a way to arrange an HTML list in this specific manner using CSS or JavaScript?

I need to arrange a list of items in columns with 5 rows each, as shown in the attached image. This list is generated dynamically using an SQL query with a loop on the li tag. I am looking for a solution to order the list in this way using javascript or ...

Animating range tick movements as the range thumb moves

My custom range input includes a span that displays the range's value and a div with multiple p elements acting as ticks. To create these ticks, I had to use a custom div because using "appearance: none" on the range hides the ticks by default. The ti ...

Is it possible to use an onclick function to input JavaScript values into a password entry box seamlessly?

Is there a way to input password values continuously using a JavaScript onclick function into a password field? I have two images, one 'Blue' and one 'Red', that trigger an onclick function with the following values: Blue= w3! Red= T4 ...

Responsive HTML grid with a distinct line separating each row

My challenge is to create a layout that features a grid of floating divs with horizontal lines under intermediate rows. The catch is that there should not be a line under the last row, and if there is only one row of elements, no line should be displayed. ...

What is the reason for the ID "home-ad" not functioning properly in Firefox?

While working on some CSS styling, I encountered an issue with the ID "home-ad" not displaying properly in Firefox. The box model was showing a content size of 0x-40 (with 40 being the padding value). Interestingly, when I changed the ID name, the code wor ...

Trouble with CSS3 Menu Layout and Gradient Display Issues

My task is to replicate this menu: I'm having trouble creating the gradient. Completed Why can't I see it in my code? http://jsfiddle.net/Vtr6d/ Here's what I currently have: CSS: .mainOptions{ float:left; margin:0 20px 0 20px; ...

Angular proxy - Syntax error found in proxy configuration file: proxy.conf.json

My Angular 6 setup is configured to make HttpRequests, but I encountered a problem that requires me to run them through a proxy. To address this issue, I created a proxy.conf.json file next to my package.json: { "/loans/": { "target" : "https://api. ...

Experimenting with the routerLink directive in Angular 2

Currently, I am in the process of testing routing functionality. As part of this, I have moved my navbar to a separate component called MdNavbar, which primarily consists of HTML and CSS. The RouteConfig is located in another component where MdNavbar is in ...

Inject HTML entities, escaped for CSS, dynamically using JavaScript

My goal is to dynamically generate a list of HTMLElements with unique data-* attributes that correspond to various HTML Entities. These attributes will then be utilized by CSS to display content in pseudo elements like this: li:after { content: attr(dat ...

Encountering a predicament when attempting to retrieve an image from an alternative

[index.jsp][5] style.css [problem][6] [folder hierarchy][7] Although everything runs smoothly when the file is located in the css directory, it fails to show any images if placed in the images folder. Kindly provide assistance. ...

The cascading style sheet used by a lightbox

I constructed a lightbox using the following HTML code: <a id="show-panel" href="#">Show Panel</a> <div id="lightbox-panel"> <h2>Lightbox Panel</h2> <p>You can add any valid content here.</p> <p align="center" ...

A guide to activating tag selection within the DevExtreme tag box

I'm currently utilizing devExtereme within my Angular project. My goal is to enable the selection of text within tags in my tagbox component. Here's what I have implemented: <dx-tag-box [dataSource]="sourves" [value]="value&quo ...