Guide on modifying fontawesome icon backgrounds when hovered over? Sample code available on jsfiddle

I am currently working on creating icons with fontawesome where the icon is placed inside an open square. I want to change the background color of the square, its actual color, and the icon color when hovering over it.

For reference, check out this example: http://jsfiddle.net/5hzv3/2/

.social-icons .fa-square-o:hover {
    background-color: #3b5998; /* The overflow is outside the square */
    color: #fff
}

The issue here is that the hover effect targets the child element of the square, not the square itself. Working on resolving this.

Answer №1

Is this what you're looking for?

fiddle: http://jsfiddle.net/5hzv3/6/

Your css code has been updated to the following:

.fa-lg:hover { color: #fff }
.fa-lg:hover > i { color: #3b5998; }

If you only want the square to change, use this code:

.fa-lg:hover { color: #fff }
.fa-lg:hover > .fa-square-o { color: #3b5998; }

Edit I've created an example that may give you some ideas. It's not a one-size-fits-all solution, but it could be helpful.

Hope this helps ... http://jsfiddle.net/5hzv3/15/

Answer №2

Expanding on the example provided by Felipe Miosso, I have discovered a way to achieve this with minimum code while still incorporating the official icons:

<style>
  .fa-stack       .fa                    { color: #000000; }
  .fa-stack       .fa.fa-square          { color: #FFFFFF; }
  .fa-stack:hover .fa.fa-facebook-square { color: #3B5998; }
</style>
<span class="fa-stack">
  <i class="fa fa-square fa-stack-1x"></i>
  <i class="fa fa-facebook-square fa-stack-1x"></i>
</span>

http://jsfiddle.net/5hzv3/27/

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

HTML5 body content and footer area

I'm working on a website with the main content area set to 95% width, but I'm facing an issue - I want the footer to be 100% width even though it's a child of the main content, which limits its width. Is there a way to make the footer overr ...

CSS tip: Keep the bottom of the screen always visible in an overflow window

My webpage has a continuously updating element where new data is added to the bottom. I currently have 'overflow: scroll' enabled for users to manually scroll down and view this new information. However, I am looking for a way to display these up ...

iOS is not recognizing the <a> tag but is instead honoring the :hover property

Within my list, I have a div element wrapped in an anchor tag. Here is an example of the code: <li> <a href="http://google.com/"> <div id="tease-info"> <div class="inset-img-border fade"></div> <img src=" ...

Achieve equal heights and vertical alignment for Bootstrap 4 accordion header with floated left and right divs

Building a Bootstrap 4 accordion, I encountered an issue. In the button header, I have two divs with one floating left and the other floating right. The right div contains an image, while the left div contains a title and a subtitle. Everything works perf ...

Obtain the text content of a span within a repeater using JavaScript or jQuery

I am facing an issue with retrieving the value of a span (or label) from my HTML code. Here is the snippet: <asp:Repeater ID="rpt_district" runat="server" > <ItemTemplate> <tbody id='bodies'> ...

Instructions for utilizing the <map> element and mouseover event to seamlessly redirect to a different webpage

I am trying to implement a feature where hovering the cursor over certain areas of an image would automatically link to another page. However, I am struggling to figure it out. Can someone help me with this issue? :( Here is just a snippet of the code whi ...

Automatically fading in a div with jQuery and fading out upon scrolling

I am relatively new to working with JQuery and currently attempting to implement a feature where a div at the bottom of the page fades in upon loading, and then fades out as the user starts to scroll down. The div should reappear when scrolling back to the ...

Implementing Conditional Display of Span Tags in React Based on Timer Duration

In my current React project, I am facing an issue with displaying a span tag based on a boolean value. I need assistance in figuring out how to pass a value that can switch between true and false to show or hide the span tag. I tried two different methods ...

Performing a function when the ondrop event of a <li> element is triggered

Is there a way to trigger a code-behind click function on the ondrop event of an <li> element? Additionally, I would like to know if it's possible to force a postback on the onclick event. Any ideas on how to achieve this? Just to clarify, thi ...

Selecting HTML tags in Visual Studio 2017

Does anyone know where to find the tag selector in Visual Studio 2017? I loved this feature in Visual Studio 2013, but I can't seem to locate it or find an extension for it. https://i.sstatic.net/NclYF.jpg In the image's bottom right corner, yo ...

The infinite slide feature isn't functioning properly when combined with a background image

I've recently implemented the infinite slide plugin, which you can find here: https://www.jqueryscript.net/slider/Infinite-Scroller-Plugin-jQuery.html. It's working flawlessly with images using the img tag, but I'm encountering some issues w ...

Data input not populating in email

After filling out the form, Gmail pops up with no data entered. How can I ensure that the information I input in the form is transferred to the email? <form class="" action="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_em ...

Discover a seamless way to update both the theme of your spreadsheet and the style and background of

My concept revolves around the ability to change the theme within a spreadsheet, with the HTML sidebar style adjusting accordingly upon reopening based on the selected theme. Initially, I extract color and font styles from the spreadsheet theme. While the ...

Place the division at the bottom of the screen

I'm facing an issue where I am trying to place a div at the bottom of the viewport but it's not working as expected. Here is how my current setup looks like: html <div class="parent"> <div class="bottom"> </div> </div&g ...

Altering the style of the underline for a hyperlink

I'm looking to customize the underline style when hovering over a link. Specifically, I want to change the color and size of the underlined link. const useStyles = makeStyles(theme => ({ button: { marginLeft: theme.spacing(2), }, }) ...

Different CSS values can be applied for specific versions of Internet Explorer by using conditional comments

I am dealing with a CSS class named "myclass" that requires a z-index of 5 specifically for IE8. I have attempted to achieve this using the following methods: .myclass{ z-index: 5\9; } ---> Interestingly, this method applies from IE10 onwards a ...

Remove the class upon clicking

I recently created a toggle-menu for my website that includes some cool effects on the hamburger menu icon. The issue I am facing is that I added a JavaScript function to add a "close" class when clicking on the menu icon, transforming it into an "X". Whil ...

The JQuery carousel displays jittery movements

The issue arises when the carousel shifts or jumps during transitions, and I'm at a loss for what might be causing it. $(".timer").css("display"); $(".timer:gt(5)").css("display", "none"); function move_first() { //console.debug("animate"); $ ...

Unable to use saved images with jQuery Slider

I'm currently facing an issue with adding a jQuery slider to my website. It seems that the slider is not displaying images that are saved on my computer, only images from external websites. Below is the code snippet where I have included an image fil ...

Select a particular column (utilizing CSS multi-column functionality)

I want to style the second column in a text block with two columns using CSS or JavaScript. How can I achieve this without creating separate containers for each column? I'm aware that I could create two containers and target the second one for styling ...