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

Steps to update the color of the asterisk in a mandatory field: How to change the

I am looking to change the color of the asterisk in my form fields from black to red. I am currently using the Material UI React library and need some guidance on how to achieve this. You can view the code here: https://codesandbox.io/s/r7lq1jnjl4 For mo ...

Turn the flipcard hover effect into an onclick action

After successfully creating interactive flip cards using CSS hover effects, I am now faced with the challenge of adapting them for mobile devices. I'm struggling to figure out how to translate my hover effects into onclick events for a mobile-friendl ...

I have a dynamic form code that allows users to insert data by adding multiple inputs in a row. However, I would like to modify it so that the inputs are added in a column instead

I found this code online that allows users to add extra inputs, but it currently only creates new rows in the database. I would like these inputs to be inserted into different columns within the same row. How can I modify it to achieve this? I have alread ...

Geocomplete Plugin without Google Branding

I've implemented the jQuery Geocomplete Library. This is what I have accomplished so far- $(function() { $("#find_product_location").geocomplete( { map: "#product_location", mapOptions: { mapTypeId : 'roadmap',//roadmap, satellite,hybrid ...

Encountering an ECONNRESET error in Next.js when making a GET request to an API within the getInitialProps function

An error has been encountered in a next.js application when sending a GET request using Axios in the getInitialProps of the _app.js file. if (typeof window === "undefined") { // user = await checkAuth(ctx); // const token = ctx.req.head ...

Step-by-step guide on positioning an image to show at the bottom of a div

I am trying to create a div that covers 100% of the screen height, with a table at the top and white space below it for an image. However, when I add the image, it ends up directly under the table instead of at the bottom of the DIV. I have searched on G ...

Unable to properly implement overrides for Material UI components in the Storybook of a React application

Within my application, I utilize React material-ui alongside storybooks for effective development. Despite this, I've encountered issues with theme overrides. Below are the theme settings: import { createMuiTheme } from '@material-ui/core/style ...

Tap on the image placeholder to replace it with your own image

Just starting out, I have the following HTML code within a <form>: <div class="image-upload"> <img id="send_photo_img1" src="assets/images/index2.png"/> <input id="send_photo_input1" type="file"/> <img id="send_photo_img2" sr ...

The Wikipedia API is unable to be loaded using the XMLHttpRequest

I have encountered this error before on this platform, and although I managed to fix it, I am seeking a more in-depth explanation of the solution. For a project where I am learning, I decided to create a Wikipedia Viewer application. The first step was to ...

Styling material-ui textfield: Tips and tricks

I've been grappling with figuring out how to customize a material-ui TextField component. <TextField id="email" label="Email" className={classes.textField} value={this.state.form_email} onChange={this.handle_change('form_e ...

Undefined is returned after resolving - React - JavaScript API

Learning React and JavaScript is a bit challenging for me, especially when it comes to understanding how Promises and resolving work. I'm currently working on an API to log into an application with an internal SQL database. The queries are functionin ...

Winning opportunities created by using credits in the slot machine

**Greetings, I have created a slot machine using JavaScript, but I am looking to enhance the player's chances based on their credits. Can anyone guide me on how to achieve this? Essentially, I want the player's odds to increase proportionally wit ...

Is there a way to get an iframe to mimic the behavior of other media elements within a horizontal scrolling container?

Take a look at this code snippet: $(document).ready(function() { $('.scrollable-area').on('wheel', function(e) { var scrollLeft = $(this).scrollLeft(); var width = $(this).get(0).scrollWidth - $(this).width(); var delta ...

React Native can trigger a press event, as long as it is not within

My situation involves triggering an action when clicking on the parent component (TouchableOpacity, for example), but not triggering anything when clicking on the children components (Screen and others). It's similar to preventing bubbling on the web. ...

How can I tally the frequency of characters in a given string using Javascript and output them as numerical values?

I am in the process of tallying the frequency of each individual character within a given string and representing them as numbers. For example, let's consider the string "HelloWorld". HELLOWORLD There is one H - so 1 should be displayed with H remov ...

What is the method for changing the icon color to dark in Twitter Bootstrap?

I am facing an issue where the icon in my menu tab turns white when active, making it difficult to see. Is there a way to change the color of the icon to black? I have found a class icon-white to make it white, but there is no corresponding class to make ...

How can I insert my URL into the webPDFLoader feature of LangChain platform?

I need help figuring out how to load a PDF from a URL using the webPDFLoader. Can someone explain how to implement this? Any assistance would be greatly appreciated. I am working on this task in nextjs. Where should I place the pdfUrl variable within the ...

What action is triggered on an Apple iPhone when a notification is tapped?

Currently, I am working on a React application and testing it on an Apple mobile phone. One issue I encountered is that when I receive an SMS, the number appears as a suggestion above the keyboard. I want to be able to tap on this number and have it automa ...

Grab the current URL using useRouter in a Next.js app

I am using userouter to obtain the URL of the current page and then utilizing the clipboard to copy it. However, I am encountering an issue where the copied content shows as object object instead of the expected URL. Can someone please help me identify w ...

Facing issues with @material-ui icons not being properly resolved on Windows OS

I am trying to incorporate Material UI into my React code, but I keep running into an issue. The error message reads: Module not found: Can't resolve '@material-ui/icons/Search' in 'C:\Users\Dominik\code\facebook&bs ...