Desktop Safari displays Font-awesome icons with trimmed corners using a border-radius of 50%

While working on incorporating font awesome share icons into my project, I encountered an issue with getting a circle around them. After exploring various approaches, I opted for a CSS solution. Using React FontAwesome posed some challenges that led me to this decision.

<FacebookShareButton 
    className='m-1' //bootstrap margin 1
    url={siteUrl}
>
    <FontAwesomeIcon className='faCircle' size="2x" icon={faFacebookF} />
</FacebookShareButton>
.faCircle {
    display: inline-block;
    border-radius: 50%;
    box-shadow: 0px 0px 2px #888;
    padding: 0.25em 0.3em;
    background-color: transparent;
    width: 1.2em !important;
    height: 1.2em;
    overflow: visible;
}

Although the code successfully displays the font awesome icons, there's an issue with the border-radius causing trimming on the sides of the icons.

(The effect is particularly noticeable on the LinkedIn icon)

If I remove the margin, the icons enlarge but are still affected by the border-radius trimming.

This problem occurs in Safari specifically, while Chrome and Firefox render the icons correctly. In Firefox, adjusting the width resolves the rendering issue.


UPDATE (including a temporary workaround)

In order to prevent white padding from covering the icon inside the circle on Safari, I had to resort to intricate adjustments for specific widths and heights. These values aren't even consistent. Any less cumbersome solutions would be greatly appreciated.

      <FacebookShareButton 
        className="m-md-1 m-1"
        url={siteUrl}
      >
        <div className='faCircleContainer'>
          <FontAwesomeIcon className='faCircle' size="2x" icon={faFacebookF} />
        </div>
      </FacebookShareButton>
.faCircle {
    width: 1.2em !important;
    padding: 0.1em;
}

.faCircleContainer {
    padding: 0.25em 0.3em;
    border-radius: 50%;
    box-shadow: 0px 0px 4px #888;
}

.react-share__ShareButton{
    padding: 5px !important;
}

Answer №1

Avoid styling the FontAwesomeIcon component/icon directly as it may disrupt the actual icon with paddings and border-radius. Instead, create a separate wrapper for each icon and apply the 'faCircle' class to this wrapper. In your case, transferring the class from FontAwesomeIcon to FacebookShareButton should resolve the issue.

Below is a screenshot from the font-awesome page showing how I edited it by styling the 'info-icons' wrapper.

https://i.stack.imgur.com/dEkkM.png

.info-icons {
    display: inline-block;
    width: 100px;
    height: 100px;
    padding: 20px;
    text-align: center;
    border-radius: 50%; 
    background: #fff;
    border: 1px solid;
}

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

Directive Template with Dynamic Fields (AngularJS)

I am interested in creating a custom directive that can bind to any object, allowing me to specify the field used in the template for display. Previously, I was limited to using {{item.Name}}, but now I want the flexibility to define the display field. Cu ...

Issue encountered: Unable to load resource - ajax file upload failed due to net::ERR_SSL_BAD_RECORD_MAC_ALERT error

I've implemented an AJAX form file upload using jQuery. After testing my code across multiple computers and browsers, I've encountered an issue on one Windows 8 machine running Chrome where the upload functionality fails with the following error ...

Navigating with Angular - sending users to an external webpage?

When working with AngularJS routes, there is the option to use an otherwise route as a replacement for a 404 error: $routeProvider .when(...) .otherwise({ redirectTo: 'my/path' }); Is it possible to configure the otherwise route to redirect ...

I am attempting to incorporate a data layer into kepler.gl using react, however, the data layer is not appearing

I'm facing an issue while attempting to programmatically add a cluster layer in kepler.gl map. Even after dispatching the data on the map, I am unable to view any layers. Any assistance with this problem would be greatly appreciated. dispatch( ...

React's componentDidMount fails to trigger for jQuery AJAX request

Here is my code snippet: import React from 'react'; import {render} from 'react-dom'; class App extends React.Component { constructor(props) { super(props); this.state = { data: '' }; ...

Utilize Google Maps to receive directions to a specific destination and discover current traffic conditions along the route using their comprehensive API

I am currently working on implementing the Google Maps direction identifier functionality with traffic details. However, I am able to obtain directions but not specific traffic details for a selected path; it seems to apply overall traffic data instead. ...

The primary tab's background color in a Shiny app

I had this question deleted previously while I was in the process of refining it. Is there a way to customize the background color of the active tab in a Shiny app? library(shiny) ui <- fluidPage( tags$head( tags$style(HTML(css)) ), tabsetP ...

"Implementing a Redux structure to enhance audio player functionality and effectively manage error

Imagine I am in the process of developing an audio player that includes a control panel for users to pause/play the currently selected track, along with the actual audio players. This involves actions such as pausing/playing the track, with the audio playe ...

What makes running the 'rimraf dist' command in a build script essential?

Why would the "rimraf dist" command be used in the build script of a package.json file? "scripts": { "build": "rimraf dist ..." }, ...

Is it possible to conceal the dates from past months in the datepicker plugin?

Currently, I am utilizing a datepicker tool from jQuery UI and adjusting its CSS to suit my requirements. My goal now is to hide any dates that are not currently active, specifically those displayed from other months. I am unsure if this can be achieved ...

Evaluate the functionality of an Angular controller method that interacts with the Document Object Model (

We currently have an AngularJS controller that contains the following function: $scope.testMe = function() { return $('#test'); } So, how can we effectively test this function? We attempted a Karma test as shown below: describe(' ...

Angular's ng serve is experiencing issues with mark-compacts near the heap limit, leading to an unsuccessful allocation

Encountering an issue while running ng serve in my Angular project. However, ng build --prod seems to be working fine. <--- Last few GCs ---> [4916:00000276B1C57010] 588109 ms: Scavenge (reduce) 8180.7 (8204.3) -> 8180.6 (8205.1) MB, 3 ...

Resolving CSS Fluid Image Problem

Even though my site background is responsive and functions well, I am encountering problems with the images. I want them to appear "fixed" in the same position as the background, regardless of resolution changes. For example, resizing the browser from 990p ...

Exploring JQuery Mobile: A guide on looping through elements in a list and collecting their unique identifiers

I am facing a challenge with a list of li tags within an unordered list. Each tag is assigned a class=listitem and a data-clicked=true/false. My task is to extract only the id's of those with data-clicked=true, add them to a string named custidlist, a ...

Transforming vanilla JavaScript into jQuery

Is there a more efficient way to write this code using jQuery? It's functioning properly in Firefox but not in Safari or Chrome without any error messages, making it difficult for me to troubleshoot. Any suggestions or insights would be greatly appre ...

Changing route causes the state from the Redux store to be lost or reset

I have been working on a simple app that currently consists of a main login component and a home page with a navbar. The intended user experience is to select a name from a dropdown menu, then click the login button to set the selected user as the authoriz ...

The toast feature in Bootstrap 5 seems to be malfunctioning as it does not display properly despite the absence of any

Why isn't the Toast displaying in the code snippet below? I'm using bootstrap 5. I'm puzzled because there are no errors in the developer's tools. Any assistance would be greatly appreciated. <!DOCTYPE html> <html lang="en"& ...

Error: unexpected syntax error at the end of the for loop in PHP MySQL

I encountered a puzzling issue with the "endif" statement after properly implementing code I found on YouTube with MySQL. <?php <?php for($x = 1; $x <= $pages; $x++); ?> <a href="?pages=<?php echo $x; ?>&per-page=< ...

Angular 7 features a table with multiple timers indicating the remaining time until expiration

I have a table with multiple rows where I need to display a timer showing the remaining time in days, hours, minutes, and seconds. After researching how to calculate the remaining time using this link, I found a solution that works well. I am calling the ...

Tips for achieving vertically centered text wrapping around a floating image

Describing it in words is proving to be difficult, so let me just illustrate it for you. In the following images, the horizontal lines represent the "text", the small box symbolizes the image, and the larger box encompasses the entire webpage. My goal is ...