Difficulty aligning Material2 icons and title text in CSS styling

I'm encountering a design problem when incorporating material2 icons into my Angular application. Specifically, I have a button that displays both a material2 icon and some text side by side from left to right. Currently, the icons are centered within the button, but the text is positioned below the icon, causing it not to be centered on the button.

Below is the HTML code:

<div id="wizard-container">
  <div class="intake-step-item">
    <span><i class="material-icons md-28">face</i></span><span class="intake-step-title">General</span>
  </div>
  <div class="intake-step-item">
    <span><i class="material-icons md-28">perm_contact_calendar</i></span><span class="intake-step-title">Availability</span>
  </div>
</div>

Here's the relevant CSS:

#wizard-container {
  box-sizing: border-box;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  z-index: -10;
}

.intake-step-item {
    background: #d7d7d7;
    width: 160px;
    height: 30px;
    margin: 5px;
    padding: 10px;
    border-radius: 15px;
    justify-content: space-around;
    align-items: center;
    text-align: center;
    z-index: 100;
}

.intake-step-item > .active {
  background: #46AB61;
}

.intake-step-title {
  display: inline-block;
  vertical-align: middle;
  text-align: center;
}

.material-icons.md-28 { 
  font-size: 28px; 
  padding: 4px; }

I attempted using negative margin and padding on the title text, but it didn't solve the issue. How can I ensure the title text of each button aligns in the center of the button?

Answer №1

All you require is

#wizard-container .intake-step-item {
  display: flex;
}

Here is a practical demonstration:

#wizard-container {
  box-sizing: border-box;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  z-index: -10;
}

.intake-step-item {
    background: #d7d7d7;
    width: 160px;
    height: 30px;
    margin: 5px;
    padding: 10px;
    border-radius: 15px;
    justify-content: space-around;
    align-items: center;
    text-align: center;
    z-index: 100;
    display: flex;
}

.intake-step-item > .active {
  background: #46AB61;
}

.intake-step-title {
  display: inline-block;
  vertical-align: middle;
  text-align: center;
}

.material-icons.md-28 { 
  font-size: 28px; 
  padding: 4px; }
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/css/materialize.min.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/js/materialize.min.js"></script>



<div id="wizard-container">
  <div class="intake-step-item">
    <span><i class="material-icons md-28">face</i></span><span class="intake-step-title">General</span>
  </div>
  <div class="intake-step-item">
    <span><i class="material-icons md-28">perm_contact_calendar</i></span><span class="intake-step-title">Availability</span>
  </div>
</div>

Nevertheless, it appears that your CSS may be conflicting with the Material Design guidelines.

Remember: Make sure to autoprefix before deploying in production.

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

One cannot loop the .click function in order to create multiple buttons

I am currently in the process of creating multiple buttons, each with its own unique function. While everything is functioning perfectly when outside of the loop, I am encountering an issue once the click function is inserted within the each loop. $.each( ...

Leveraging Font Awesome with Google's Autocomplete in Pac-Input

I'm experimenting with using the Font Awesome Map Marker in a Google Autocomplete Input. My aim is to position the Map Marker to the left of the placeholder text, apply color only to the map marker, and ensure that it remains visible even while the us ...

Navigating within fixed-positioned divs

I'm attempting to create something similar to the layout seen on: The desired effect is to have fixed content on the right side, with only the left side scrolling up to a certain point before the entire page scrolls normally. However, in my implement ...

Unlock the power of AngularJs to transform your website into a multilingual platform

When I apply multiple directives as a template, it results in making multiple API calls. How can I avoid this and find a good solution? Please comment. var directive = { restrict: 'AE', scope: false, multiElement: tru ...

Receive dual responses in a single express post

I have a question regarding making multiple requests in one post in Express and receiving multiple responses on the client side (specifically Angular). When I try to make two res.send(body) calls, I encounter an error stating: Error: Can't set headers ...

How to eliminate the validation icon from a select tag in Bootstrap 5?

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="23414c4c57505751425363160d110d11" ...

Align select and number inputs vertically in Firefox

How can I achieve vertical alignment for these inputs on Firefox? The alignment works perfectly in Chrome, Safari, and Opera, but not in Firefox (Version 57 tested on macOS, Windows, and Linux Mint). While removing type="number" from the input resolves th ...

Creating a unique CSS selector to locate the pages tab on Facebook using Selenium

My attempt to direct my chrome driver to the correct CSS locator in order to refine the search only to Facebook pages is proving to be a challenge. When inspecting the element, the HTML code is as follows: https://i.sstatic.net/8XVPs.png I decided to manu ...

How to Create a Speech Bubble in SVG Using SnapSVG

In the process of developing a chat program, I have animated figures moving across the screen engaging in conversations. One crucial aspect I am yet to implement is creating scalable speech bubbles for when users interact. Being relatively new to SVG and ...

The content does not fill the entire page's height

I am facing an issue with a linear-gradient background image that does not extend to cover the entire content height. I have experimented with different solutions like using min-height: 100% and adjusting the positioning of the html and about-body divs, b ...

Import the information into a td tag's data-label property

I have implemented a responsive table design that collapses for smaller screens and displays the table header before each cell. body { font-family: "Open Sans", sans-serif; line-height: 1.25; } table { border: 1px solid #ccc; border-collapse: co ...

Incorporating Tailwind CSS into Vue transitions reveals an issue where the fade out effect

I'm working with Tailwind CSS and Vue.js to create a modal component. Since Tailwind doesn't natively support Vue 2, I had to implement the transitions myself. You can check out the desired effect here. Below is the code snippet: <template> ...

Using Grails assets within AngularJS templates

Currently, I am developing a basic application using Grails 2.4.4 in combination with AngularJS 1.3.15. In order to integrate templates with Grails, I have incorporated the AngularJS Template Asset-Pipeline Plugin 2.0.7. Initially, my application did not ...

Having trouble with Angular JS $scope.$apply due to an interpolation error displaying "TypeError: Converting circular structure to JSON"?

I have created a specialized angular directive shown below: dirs.directive('sectionInfo', function(){ return { restrict: 'E', templateUrl: 'partials/section-home.html', transclude: true, co ...

Navigating within a nested view using Angular's UI-Router

I've encountered a puzzling issue that I've been grappling with for the past three days. It seems like a straightforward problem, but for some reason, it's causing me a lot of trouble. The main parent view in my code contains two child view ...

The functionality of $watch is not functioning correctly within the Modal, despite implementing it with $scope.user={pwd1:''}

For the Plunker link referenced, please click here: http://plnkr.co/edit/0vOjw0?p=preview index.html <!DOCTYPE html> <html ng-app="app"> <head> <link rel="stylesheet" href="style.css"> ...

Tips for redirecting after an email has been successfully delivered

As a beginner in PHP, I've successfully set up an email system for a contact form on my website's front end. However, after sending the email, I want to hide the form and show a "thank you for the email" message. I've searched for solutions ...

How to center align text in the media-body using Bootstrap 4 Beta

Struggling to vertically align the text in media-body to the middle when using the new Bootstrap 4 beta version. Tried an approach mentioned in this solution, but it didn't work with the latest version of Bootstrap. Attempted using text-center and a ...

JS causes the navigator to malfunction

UPDATE: Greetings! I have developed a navigation bar that loads various pages into a specific div. Here is the source code for the navigation bar: <div id="navBar"> <ul> <li><a href="#" onClick="document.getElementById('bott ...

Angular dependencies cannot be injected because $scope is not defined

Currently, I am utilizing the latest version of angularjs (1.3.3): I have integrated 3 JavaScript libraries into my project. <script src="framework/jquery-1.9.1.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3 ...