Looking for Angular 2 material components for dart with CSS styling? Need help centering a glyph on your page?

HTML:

<div class="border">
    <glyph  class="center" [icon]="'star'" ></glyph>

    <div class="centerText">
        This Is Text that is centered.
    </div>
</div>

Css:

.centerText{
    text-align: center;

}

.border{
    border: solid black;
    width: 80px;
}

.center{
    margin-left: 50%;
}

Result:

https://i.sstatic.net/ThHgh.png

I am currently attempting to align a glyph icon sourced from https://github.com/dart-lang/angular2_components

What approach should I take in order to center the glyphs?

The css code found in https://github.com/dart-lang/angular2_components/blob/master/lib/src/components/glyph/glyph.scss.css implements flexbox with the property -> display: inline-flex

Although the margin-left method somewhat assists in alignment, it fails to produce satisfactory results when the width is reduced. The following methods were unfruitful:

text-align: center

as well as

align-items: center;
justify-content: center;

and finally

display:block;
margin:auto;

Answer №1

Following micronyks' suggestion, here is the updated solution:

<div class="border">
    <div class="centerText">
        <glyph [icon]="'star'" ></glyph>
    </div>
    <div class="centerText">
        Text in the middle of the screen.
    </div>
</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

Styling Dynamic HTML Content in Angular: Tips and Tricks

After running this line of code, I have a generated element sub with a property of [sub]. <li [displayMode]="displayMode" template-menu-item style="cursor: pointer" [routerLink]="['/request/checkoutReview']" icon="fa-shopping-cart" name ...

Step-by-step guide to implementing a sticky header while scrolling

How can I implement a fixed header on scroll, like the one seen on this website: www.avauntmagazine.com Here is the HTML for my header: <div class="bloc bgc-wild-blue-yonder l-bloc " id="bloc-1"> <div class="container bloc-sm"> &l ...

Continuously encountering CORS errors despite activating them, using .NET Core in conjunction with an Angular client

I recently encountered a CORS issue in my .NET Core 3.0 Web API project despite having enabled CORS in the startup file. Here's how I configured it: ConfigureService services.AddCors(options => { options.AddPolicy("AllowOrigin", builder => b ...

I encountered an issue while trying to implement a custom pipe using the built-in pipe

My custom pipe seems to be functioning well, except for the built-in pipes not working within it. I've imported Pipe and can't figure out what could be causing the issue. Below is the code with the errors: import { Pipe, PipeTransform } from &a ...

issue with ng2-semantic-ui: remote options not properly loading in select

public optionsLookup(query:string, initial:any): Promise<any> { return new Promise ( (resolve, reject) => /*[{ id: 1, name: 'ololo1'}, { id: 2, name: 'ololo2'}]*/ this.apiService.get('private/count ...

Error Encountered: Unable to locate control within nested form array: 'module -> 0 -> view'

I am creating a Form Array with Nesting, using Reactive Forms in Angular 7. I am encountering this error: ERROR Error: Cannot find control with path: 'module -> 0 -> view' I have built the Nested Form but keep getting errors. Please help m ...

What is the process for obtaining an app icon from the store using Angular?

Currently, I am working on an app using ionic, angular, and Cordova. Within this app, there are links to other apps available in the app store. My main query is: Is there a way to retrieve the icons of these apps from the store? I aim to display these ic ...

Efficiently transfer large files in segments with Flutter using the dio package

I came across this package but I'm not sure how to upload large files in chunks. The file size I need to upload is 100MB. I am currently using Dio for posting files to the server and the filePicker plugin to select multiple files. Can someone please ...

Ways to Adjust the Earth's Position in WebGL Earth

I have been working with this WebGL Earth component for my project, but I am facing difficulty in adjusting the position of the planet on the canvas. My intention was to place the planet at the bottom of the page, but I haven't been able to achieve th ...

What are your thoughts on combining a JSON object with HTML?

When using ASP.NET MVC, it is possible to return a JSONResult. return JSON(new { View = RenderViewAsString("MyView", model), wasSuccessful = true}) This approach combines HTML and data in a single JSON object. The goal is to utilize strongly typed HtmlHe ...

AngularJS: How to automatically scroll to the bottom of a div

I cannot seem to scroll to the last message in my chat window. var app=angular.module('myApp', ['ngMaterial'] ); app.controller('ChatCtrl', function($window, $anchorScroll){ var self = this; self.messageWindowHeight = p ...

Attempting to incorporate Font-Awesome Icons into the navigation bar tabs

As a newcomer to React, I've been attempting to incorporate Font Awesome icons into my secondary navigation bar. Despite using switch-case statements to iterate through each element, all the icons ended up looking the same, indicating that only the de ...

Mastering Nested *ngFor in Angular

I attempted to use nested for loops in Angular but I couldn't achieve the exact result I wanted. I tried different approaches, but none of them gave me the desired outcome from this nested loop function. I am looking to create a select box based on n ...

Discover the hidden content within a div by hovering over it

Here is an example of a div: <div style="width:500px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce quis pulvinar dui. Nulla ut metus molestie, dignissim metus et, tinc ...

"I am experiencing an issue with the PrimeNG year picker as it is unable

My goal was to set up a simple PrimeNG calendar with just a year picker. I followed the implementation instructions from the documentation: <p-calendar inputId="year" [(ngModel)]="date1" view="year" dateFormat=" ...

What could be causing my difficulty in locating an HTML element using jQuery/JS string interpolation?

In my project, I have a set of div blocks each identified by a unique numerical id. For instance: https://i.sstatic.net/lYod8.png One of the tasks in my project is to select the 29th element following a specific chosen element. For example, if I choose t ...

Is it necessary to mark all checkboxes in the initial column of the gridview?

I have encountered an issue with my code that checks all checkboxes in the first column of a gridview. It seems to work only for Internet Explorer versions 5.0 to 8.0, but gives a Javascript error when running on IE 9 and above stating "Function Expected ...

Checking for empty inputs using Html, JavaScript, and CSS

I need help with a form that has 6 input fields. I want to ensure all fields are filled out, and if not, display an alert message. Any suggestions on how to achieve this? Additionally, I'm experiencing difficulties implementing different font styles. ...

Developing an Angular feature to categorize options within a dropdown menu

I am currently working on a project that involves utilizing a lot of data related to selects. Is there a way to organize this data using built-in Angular (5/6?) functions? I attempted to use the ng-select component but it didn't meet my requirements. ...

Exploring data retrieval from nested arrays of objects in TypeScript/Angular

I have an API that returns an object array like the example below. How can I access the nested array of objects within the JSON data to find the role with roleid = 2 when EmpId is 102 using TypeScript? 0- { EmpId: 101, EmpName:'abc' Role : ...