Utilizing Unique Icons for HTML Button Design

Currently, I am in the process of developing a mobile application with IONIC 2. Within this app, there is a group of buttons present, three of which utilize the standard Ionicons resources. However, one button stands out as it incorporates a custom image of a key. Unfortunately, this particular image does not appear to be scaled correctly based on my observations.

https://i.sstatic.net/1trLV.png

The following showcases my code:

scss:

.buttons .key { 
    background-color: #de574b;       
    transform:rotate(45deg);
    -moz-transform:rotate(45deg);
    -webkit-transform:rotate(45deg);
    -o-transform:rotate(45deg); 
}

.ion-ios-key::before, .ion-md-key::before {
    max-height: 20px;
    align-content: center;
    vertical-align: center;
    content: url('../../img/Key.png');
}

html:

<div class="buttons">
    <button class="bluetooth">
        <ion-icon name="bluetooth"></ion-icon>
    </button>

    <button class="help">
        <ion-icon name="md-help"></ion-icon>
    </button>

    <button class="key">
        <ion-icon name="key"></ion-icon>
    </button>

    <button class="new" (click)="newDevice()">
        <ion-icon name="md-add"></ion-icon>
    </button>
</div>

I have tried using the max-height property along with a height property, but neither seem to affect the icon's appearance. Does anyone know how to properly style this icon so that it blends in seamlessly with the rest?

Answer №1

align-content is designed to function exclusively with display: flex, flex-direction: column, and flex-flow: row wrap (in specific scenarios).

Consider trying this:

.ion-ios-key, .ion-md-key {
      line-height: 20px;
      vertical-align: center;
      background: url('../../img/Key.png')no-repeat;
      background-size: contain;
    }

Eliminate the following:

.ion-ios-key::before, .ion-md-key::before {
      max-height: 20px;
      align-content: center;
      vertical-align: center;
      content: url('../../img/Key.png');
    }

If you utilize background-size: contain;, your image will automatically be centered and scaled to maintain its aspect ratio without clipping. In case of unsatisfactory positioning, consider using background-position: center or background-position: 45% 45%*

*The values like 45% 45% are purely for illustrative purposes.

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

Registration form input field in ReactJS keeps losing focus with every keystroke

Currently, I am in the process of creating a registration form for a website. I have implemented the handleChange function to alter the input text in the regData state. However, I am encountering an issue where every time I type something into an input fie ...

Adjusting element placement on collapsed navbar using Bootstrap

I've been developing a navbar for a webpage and have successfully aligned the data left and right with the Brand in the center. However, when the navbar collapses, the alignment shifts to Left (over) Brand (over) Right. I want the Brand to remain at t ...

Horizontal Scrolling Menu for Dynamic Page Navigation

My goal was to create a smooth-scrolling one-page website that scrolls horizontally. One feature I wanted was a menu that smoothly slides into view whenever a new page is in focus along with the horizontal scrolling. I found an example of a scrolling scr ...

Utilizing drop-down pagination with Jquery

<select multiple> <option></option> <option>a1</option> <option>b1</option> <option>c1</option> <option>d1</option> . . . . . <option>u100</option> < ...

Transform to CSS Selector

Having trouble clicking on the image button below using Xpath? Here is the HTML tag for the Image Button: HTML Script <img src="../../../../imagepool/transparent%21tmlservicedesk?cid=1" id="reg_img_304316340" aralttxt="1" artxt="Show Application ...

What could be causing the unequal sizes of my flex children?

After some investigation, I have discovered that the issue I'm experiencing only occurs on certain devices, indicating it may be related to the viewport size. In the code provided, the parent element has a fixed height and width, while the children a ...

Having trouble locating images and JavaScript files on GitHub Pages

Using a template from this source to create a react website with interactions involving smart contracts, I successfully got everything up and running smoothly on my localhost. All the features of the site were functioning correctly and images were displayi ...

Convert a decimal number to a suitable Alpha value for an RGBA CSS color

I'm currently working on filling a Canvas element with a linear gradient that transitions from White to a dynamic color that will be determined at runtime. In order to achieve this, I have written a function that takes a floating-point number as its ...

Tips on creating a blurred background effect when an HTML popup modal is activated

Whenever I click on a button, a popup window appears. What I want is for the background to be blurred when this popup modal opens. <div class="modal" id="myModal"> <div class="modal-dialog modal-lg"> <div class="modal-content"> ...

Failure to Connect HTML with Stylesheet

Feeling a bit lost here. I've been attempting to connect my homepage to my stylesheet, but no matter how often I refresh the page, it just won't recognize the link. I'm diligently following the instructions from the guide I have, copying and ...

Using jQuery to create an array variable and Passing the array to a different PHP page

Although I have managed to create a function that works perfectly for me, I am facing an issue with the jQuery part at the bottom. Currently, I am only able to trigger an alert message and not store the data as a real variable. The function is functionin ...

The presence of text is leading to CSS placement troubles

I operate a website dedicated to comic content and am looking to incorporate text (retrieved from the database field "description") beneath each comic thumbnail. Here are my two inquiries: 1) I'm facing an issue where adding text below a comic caus ...

Break the line using HTML select option and set it as the value

I am working on a select box where I want to include a value for a line break. <select> <option value=";">Semicolon</option> <option value=",">Comma</option> <option value=".">Dot</option> <opti ...

Is it possible to customize the appearance of elements that are disabled using the [disabled] attribute in Angular 8?

I currently have a button on my website that triggers a form: <button (click)="create()" *ngIf="data.new" [disabled]="!dataForm.valid" color="primary" mat-raised-button> Go </button> Under specific conditions, this button disables all fiel ...

How can I center a button instead of using "margin-left: 0" when its location changes on a smaller screen?

Website: When viewing the website on my desktop, the text over the top image - "Buckinghamshire Food Partnership believe that everyone is entitled to a Right to Food" and the button - "Get involved" are aligned to the left with a 10% margin. However, on a ...

Ways to consistently pause background image in CSS?

I have successfully created a slider using the Slider Revolution Wordpress plugin and am currently customizing it with CSS. I have added a small open space within the slider to display logos of the technologies that I am utilizing. Around this space, I hav ...

Strategies for detecting changes in multiple HTML select elements with jQuery

I currently have three select HTML tags and I would like to filter my table using the selected values (group of selected tags) with an AJAX request. For example, filtering by Gender, Location, and Season. My question is how can I achieve this without dup ...

Turn off the div element until a radio button option is selected, then activate it

Is there a way to disable a div and then activate it only after selecting a radio button option? I know how to hide and show the div when an option is selected, but using the hidden property is not ideal. Can someone suggest a possible solution? <div ...

The overflow property's auto and scroll functions are not functioning properly

I stumbled upon this amazing theme that has captured my heart. Start Bootstrap template I am planning to use this theme for my portfolio website, but I need to make a few modifications to achieve my desired look. When you click on any of the thumbnails, ...

Issue with hiding elements in Bootstrap 4 Beta using display none

Currently experimenting with Bootstrap 4 beta through the CDN, I have encountered a peculiar issue with the newly introduced d-* class. Upon trying out a simple div with the class "d-none d-lg-block", it performed as expected, being visible only when the ...