Looking for a clever CSS hack to remedy this problem

Hey everyone, I'm currently designing a website with a vibrant orange background and incorporating white social icons from the Font Awesome library.

Check out the progress of my project below:

CSS

@import url('http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
@import url('http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css');

body {
margin: 10px;
background:#da4a10;
}
#social:hover {
-webkit-transform:scale(1.1); 
-moz-transform:scale(1.1); 
-o-transform:scale(1.1); 
}
#social {
-webkit-transform:scale(0.8);
-moz-transform:scale(0.8);
-o-transform:scale(0.8); 
-webkit-transition-duration: 0.5s; 
-moz-transition-duration: 0.5s;
-o-transition-duration: 0.5s;
}   
.fa-3x{
color: white;
}
.social-fb:hover {
color: #3B5998;
}
.social-tw:hover {
color: #4099FF;
}
.social-gp:hover {
color: #d34836;
}
.social-em:hover {
color: #f39c12;
}

HTML

<div id="row">
<div class="col-xs-2 col-sm-8 col-lg-2 col-md-6">
<a href="#">
<i id="social" class="fa fa-facebook-square fa-3x social-fb"></i>
</a>
</div>
<div class="col-xs-2 col-sm-8 col-lg-2 col-md-6">
<a href="#">
<i id="social" class="fa fa-twitter-square fa-3x social-tw"></i>
</a>
</div>
<div class="col-xs-2 col-sm-8 col-lg-2 col-md-6">
<a href="#">
<i id="social" class="fa fa-google-plus-square fa-3x social-gp"></i>
</a>
</div>
<div class="col-xs-2 col-sm-8 col-lg-2 col-md-6 ">
<a href="#">
<i id="social" class="fa fa-envelope-square fa-3x social-em"></i>
</a>
</div>
</div>

http://jsfiddle.net/DTcHh/5582/

I'm seeking guidance because when hovering over the social icons, the appearance is not as appealing as I would like. I attempted to add a white background to the icons, but it hasn't resolved the issue.

Answer №1

Utilizing Font Awesome provides access to an icon named fa-square, which closely resembles the square shape of various social media icons. Additionally, Font Awesome allows for stacking icons, so by layering a white fa-square underneath a fa-twitter-square, for example, you can easily resolve your issue.

HTML

<div id="row">
    <div class="col-xs-2 col-sm-8 col-lg-2 col-md-6">
        <a href="#">
            <span class="fa-stack fa-2x social social-fb">
                <i class="fa fa-square fa-stack-1x white-bg"></i>
                <i class="fa fa-facebook-square fa-stack-2x "></i>                    
            </span>
        </a>
    </div>
    <div class="col-xs-2 col-sm-8 col-lg-2 col-md-6">
        <a href="#">
            <span class="fa-stack fa-2x social social-tw">
                <i class="fa fa-square fa-stack-1x white-bg"></i>
                <i class="fa fa-twitter-square fa-stack-2x "></i>                    
            </span>
        </a>
    </div>
    <div class="col-xs-2 col-sm-8 col-lg-2 col-md-6">
        <a href="#">
            <span class="fa-stack fa-2x social social-gp">
                <i class="fa fa-square fa-stack-1x white-bg"></i>
                <i class="fa fa-google-plus-square fa-stack-2x "></i>                    
            </span>
        </a>
    </div>
    <div class="col-xs-2 col-sm-8 col-lg-2 col-md-6 ">
        <a href="#">
            <span class="fa-stack fa-2x social social-em">
                <i class="fa fa-square fa-stack-1x white-bg"></i>
                <i class="fa fa-envelope-square fa-stack-2x "></i>                    
            </span>
        </a>                 
    </div>
</div>

CSS

/* Optional theme */
@import url('http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
@import url('http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css');

body {
    background: #DA4A10;  
    margin: 10px;      
}
.social {
    color: #F9F9F9;
    transition: 0.5s;
    -moz-transition: 0.5s;
    -ms-transition: 0.5s;
    -o-transition: 0.5s;
    -webkit-transition: 0.5s;     
}
/* Define white background properties */
.white-bg {
    color: white;
    font-size: 54px;
    opacity: 0;
    transition: 0.5s;
    -moz-transition: 0.5s;
    -ms-transition: 0.5s;
    -o-transition: 0.5s;
    -webkit-transition: 0.5s; 
}  
.social-fb:hover{
    color: #3B5998;
}
.social-tw:hover {
    color: #4099FF;
}
.social-gp:hover {
    color: #d34836;
}
.social-em:hover {
    color: #f39c12;
}
/* Display white background on hover */
.social-fb:hover .white-bg, .social-tw:hover .white-bg,
.social-gp:hover .white-bg, .social-em:hover .white-bg {    
    opacity: 1;
}

View the solution in action: http://jsfiddle.net/DTcHh/6084/

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

Ways to enable users to use the keyboard tab to navigate and choose hidden checkboxes with labels that are visible

I am currently configuring "card" style checkboxes where there are three hidden checkboxes (opacity: 0) with corresponding labels displayed as boxes with backgrounds. Clicking on the label selects the checkbox and changes its label to a blue background. E ...

When adding text to a React Material UI Box, it can sometimes extend beyond the boundaries

I'm currently working on a straightforward React page, but I've encountered an issue right from the start: my text is overflowing the box and I can't figure out why. Could someone take a look at my styles? Here's a picture showing the ...

Preserving distance between absolute elements

I'm facing an issue with my menu animation using jQuery. In order to achieve the desired effect, I am forced to use position: absolute. My challenge is maintaining consistent spacing between each text string, especially since they vary in width. Unfor ...

Configuring a Revolution Slider 5+ layer to display as a fixed layer

I wish to keep a consistent shape below my text on all the slides without any flickering. Although Revolution Slider offers static layers, they always appear on top and cannot be layered beneath other slide layers. I attempted to create a layer with no t ...

place an image next to a div element

Currently, I have a table-like structure with two columns that I am struggling to make mobile responsive. Take a look at the code snippet below: setTimeout(function() { odometer.innerHTML = '1925' }) .fiftyFiftySection { back ...

The Popover style from React-Bootstrap seems to be missing when applied to my component

Attempting to incorporate a Popover with overlay trigger from React - Bootstrap has proven to be quite the challenge. If you check this image, you'll see what it's supposed to look like. This is the code I used: var {Button, Overlay, OverlayTr ...

Using media queries within specific CSS classes

I am attempting to create the following CSS code: .myClass { @media all (max-width: 1024px) { left: 33%; } @media all (min-width:1025px) { left: 25%; } } Unfortunately, it doesn't seem to be working as expected. Is t ...

css, predetermined dimensions

I am looking to create three tables within divs. The left and right sides should each take up 50% of the available window space. The center table should remain fixed. Everything appears to be working correctly, except the content on the right side is over ...

Hide Bootstrap columns for Printing

I am currently working on a webpage layout that consists of two columns. <div class="container"> <div class="row"> <div class="col-md-8 "></div> <div class="d-print-none col-md-4"></div> </div ...

Struggle with the background div menu

I am trying to create a menu with a background color, but when I use "background" or "background-color" on the div that contains my menu, I can't see any color. It's frustrating because I know it should be working.. Here is the HTML : <head ...

Please rewrite the following sentence: "I am going to the store to buy some groceries."

As I navigate through my styled HTML page, an interesting sequence of events unfolds. When the Create New List button is clicked, a pink div emerges, contrasting with the orange hue of the All Lists div. At this moment, a new user has joined but hasn' ...

How can Play framework be used to display static HTML pages with static JavaScript and CSS files?

I'm currently exploring options for rendering or routing to static web apps stored in the Play's public folder. Here is my project structure: myapp + app + conf + modules + public | + webapp1 | + css | + ...

Utilizing CSS classes to style custom day templates in ng-bootstraps datepicker

Currently, I am utilizing ng-bootstraps datepicker to showcase user data on a daily basis. I have implemented a custom day template to apply specific CSS classes. <ng-template #customDay let-date> <div class="custom-day" [ngCla ...

Issue with React rendering numbers without displaying div

In my user interface, I am attempting to display each box with a 1-second delay (Box1 after 1 second, Box2 after another 1 second, and so on). https://i.sstatic.net/FdTkY.png However, instead of the desired result, I am seeing something different: https ...

What is the best way to horizontally center a child div within its parent container while keeping it fixed at the top?

I am struggling to center a child div horizontally within its parent div while also fixing it to the top of the parent. I have tried various approaches in CSS, but so far I haven't been successful :-( I can either center it or fix it to the top, but w ...

Calculating the CSS `top` value for a sticky table header without the use of Javascript

Is it possible to dynamically adjust the height of a sticky table header bar in CSS, rather than using JavaScript to compute and apply the height? While I am aware that CSS variables can fix the height at 50px, I would prefer for the height to be determin ...

Footer not sticking to the bottom of the page with Material UI

View Page Screenshot My challenge is with the Footer using AppBar when there is no content. It doesn't properly go to the end of the page, only to the end of the content. I want it to stick to the bottom of the page if the content doesn't reach ...

Display radio buttons depending on the selections made in the dropdown menu

I currently have a select box that displays another select box when the options change. Everything is working fine, but I would like to replace the second select box with radio buttons instead. Can anyone assist me with this? .sub{display:none;} <sc ...

I would like to conceal any div elements with an href attribute and a certain unique structure, but not every single div on

I am seeking to conceal all div elements that contain the href attribute as shown below: <div style="margin-left:36.847599164927%;margin-top:-30.27139874739%;width:19.72860125261%"><a href="//www.exemple.com/item/detail/400010589111 ...

Eliminate the navigation bar option from a website template

Is there a way to permanently eliminate the menu button in this theme? Any guidance would be appreciated. Here's the link to the theme: https://github.com/vvalchev/creative-theme-jekyll-new ...