Surprising sight of a blank canvas behind the font-awesome icon

Is there a way to remove the unexpected white background that appears when adding a font-awesome icon?

Here is the HTML code:

<div class="notifications-window" id="close-notifications">
<div class="notifications-header">
    <h4>Notifications</h4>
    <button type="button" onclick="closenotifs()"><i class="fas fa-window-close"></i></button>
</div>
<div class="notifications-details">
    <p>Congratulations! Login Reward: 2 credits</p>
    <p>Congratulations! Login Reward: 2 credits</p>
</div>

CSS Code:

.notifications-window {
width: 350px;
border: 3px solid rgb(0, 0, 0);
background-color: rgb(160, 156, 156);
color: #fff;
border-collapse: collapse;
border-radius: 5px;
text-align: center;
list-style-type: none;
display: inline-block;
}

.notifications-window p {
font-size: small;
padding: 5px;
background: rgb(141, 136, 136);
border-radius: 5px;
margin: 5px;
}

.notifications-details {
overflow-y: auto;
max-height: 350px;
}

.fa-window-close {
display: inline-block;
float: right;
justify-content: right;
cursor: pointer;
text-decoration: none;
text-align: center;
color: #000;
background-color: #fff;
border: none;
outline: none;
transition: background 250ms ease-in-out, 
            transform 150ms ease;
-webkit-appearance: none;
-moz-appearance: none;
}

Take a look at this image to see how the icon looks after styling

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

Answer №1

The button's background is controlled by the User Agent Stylesheet. To learn more about the user agent stylesheet, you can visit here.

If you want to change the button's background, you can create your own styles. I have created a .button class for the button and removed the background-color: #fff; property from your .fa-window-close class. Here is an example:

CSS:

.notifications-window {
            width: 350px;
            border: 3px solid rgb(0, 0, 0);
            background-color: rgb(160, 156, 156);
            color: #fff;
            border-collapse: collapse;
            border-radius: 5px;
            text-align: center;
            list-style-type: none;
            display: inline-block;
        }

            .notifications-window p {
                font-size: small;
                padding: 5px;
                background: rgb(141, 136, 136);
                border-radius: 5px;
                margin: 5px;
            }

        .notifications-details {
            overflow-y: auto;
            max-height: 350px;
        }

        .fa-window-close {
            display: inline-block;
            float: right;
            justify-content: right;
            cursor: pointer;
            text-decoration: none;
            text-align: center;
            color: #000;
            /*background-color: #fff;*/
            border: none;
            outline: none;
            transition: background 250ms ease-in-out, transform 150ms ease;
            -webkit-appearance: none;
            -moz-appearance: none;
        }
        .button {
            background: transparent;
            border: none;
        }

HTML:

<div class="notifications-window" id="close-notifications">
    <div class="notifications-header">
        <h4>Notifications</h4>
        <button type="button" onclick="closenotifs()" class="button"><i class="fas fa-window-close"></i></button>
    </div>
    <div class="notifications-details">
        <p>Congratulations! Login Reward: 2 credits</p>
        <p>Congratulations! Login Reward: 2 credits</p>
    </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

Gone Without a Trace: Where Did the WP Admin

I am brand new to creating WordPress themes and I have just started working on my very first one. I have managed to get some content up and running, and the home page is functioning properly. However, when I log into WordPress and view the site, I noticed ...

Display the menu and submenus by making a request with $.get()

My menu with submenu is generated in JSON format, but I am facing issues displaying it on an HTML page using the provided code. Can someone please assist me in identifying what mistakes I might be making? let HandleClass = function() { ...

checkbox toggling event triggering twice

I have been working on an application that allows users to register for university courses. They can select their registration type, course type, batch, and subjects. The subjects are displayed in a table based on the selected course type and batch. Users ...

Storing css data for iPhone Facebook application

Currently, I am in the process of developing a webpage specifically for the iPhone Facebook app wall link. Interestingly, when attempting to apply the margin attribute to a div within the webpage, the margin doesn't seem to have any effect when clicki ...

What are the most effective strategies for creating cross-platform components using Vue.js 2.0?

In my current project, I am looking to create a universal component library using Vue.js 2.0 that can be seamlessly integrated across various platforms. The focus of this query lies in establishing the most effective styling practices for components. Typi ...

Can one use Flexbox inside another Flexbox?

I am attempting to create a layout that looks like this: +---------+---------------------+ |legend | | +---------+ | |csv_input| map | | | | | | ...

Height not being generated by Div element

I am encountering an issue with a div element that contains an h2 and three nested div elements. Despite not explicitly setting a height for the container div, it is not expanding to accommodate the varying heights of the inner divs. This problem is causin ...

When the progress bar is clicked, the background color changes and then changes back again

https://www.w3schools.com/code/tryit.asp?filename=FG1ZE0NJ4ZX7 https://i.stack.imgur.com/Bnd0k.png I have created a progress bar that resembles the screenshot provided. When I hover over it, the color changes to green. However, I am looking for assistanc ...

Difficulty with implementing CSS Sprites in a jQuery-driven menu

Facing issues with a code base that was previously owned by someone else. Deadline is approaching fast and struggling to solve a particular issue. This code includes a table in the top section of the page, featuring a drop-down menu using CSS sprites for ...

Hide the Modal Content using JavaScript initially, and only reveal it once the Onclick Button is activated. Upon clicking the button, the Modal should then be displayed to

While trying to complete this assignment, I initially attempted to search for JavaScript code that would work. Unfortunately, my first submission resulted in messing up the bootstrap code provided by the professors. They specifically requested us to use Ja ...

Chrome: When enlarging an image, the overflow of the outer div is disrupted

My image wrapper is designed to hide overflow when hovered over. It works well in Firefox and Opera, but Chrome displays it strangely. I've created a 10-second screen recording to demonstrate the issue. Watch it here: I also tested it on JSFiddle, ...

What is the best way to show toast notifications for various selections in a dropdown menu?

I have a dropdown menu labeled "FavoriteFoods" that includes options such as "Pizza," "Sushi," "Burgers," and "Biryani." When one of these food choices is selected from the dropdown, I would like a toast pop-up to appear with the message "Great choice!" ...

"Troubleshooting issue in Django 1.6.2 where CSS styles are not being applied to

I am encountering an issue with this code and would greatly appreciate some assistance. The base.html file contains a {% block content %}{% endblock %}. I have created a Signup.html file structured like this: {%extends 'base.html'%} {% block co ...

What is the reason for the .foo a:link, .foo a:visited {} selector taking precedence over the a:hover, a:active {} selector in CSS?

Sample code: http://jsfiddle.net/RuQNP/ <!DOCTYPE html> <html> <head> <title>Foo</title> <style type="text/css"> a:link, a:visited { color: blue; } a:hover, a:active { ...

Customize the appearance of the bootstrap nav-bar by assigning unique background colors to each dropdown menu

I'm looking to set unique background colors for each dropdown in a Bootstrap nav-bar using CSS. .mynavbar .dropdown ul.dropdown-menu:nth-child(1) { background-color: #59b057; } .mynavbar .dropdown ul.dropdown-menu:nth-child(2) { background-col ...

An easy way to incorporate a fade-in effect for every word in a text

I am trying to make the text "Eat. Sleep. Repeat." slide up and fade in one word at a time. I have experimented with various methods like anime.js, keyframes, and adding css classes, but so far none of them have worked for me. Here is the code I currently ...

Incorporating a divider into a Material-UI MenuItem causes an additional border

I needed a way to separate the MUI MenuItem using a divider, but it resulted in an extra border around the item where the divider was placed. The highlighted section in the image shows the item that has the divider= true setting and the extra border. Is th ...

How to perfectly align content on a webpage

Can someone help me understand why my webpage is off-centered as it scales up? I have set a minimum width of 1000px, but it still appears to be centered at 30%-70%. Any insights on this issue would be greatly appreciated. <!DOCTYPE html PUBLIC "-//W3 ...

Purge the external CSS files

Scenario In my React Router setup, most pages include their own .css files along with the default antd (UI framework) stylesheet: import '../styles.css'; This ensures that all components inherit these styles automatically. Issue at Hand Now, I ...

What is the best method for securing my API key within the script.js file while utilizing dotenv?

My goal is to conceal my API key using dotenv. Interestingly, when I replace require('dotenv').config(); with my actual API key in the code as apiKey: process.env.API_KEY, it works fine despite not using process.env.API_KEY. I made sure to inst ...