mercredi 22 juin 2016

Unexpected distortion of Font Awesome Icons placed inside CSS created Hexagon


I'm attempting to add social media icons using the Font-awesome i tag with fa class to a Hexagon background. The social media icons should all sit next to each other inside hexagon backgrounds and change background color on hover. However the problems I'm getting are as following:

UPDATE The fiddle is almost right, we just need to be able to make the shpae look like a Hexagon https://jsfiddle.net/onkkdef6/4/

enter image description here

Problems:

1. The social media icons are warped by the hexagon

2. The hexagon now won't change background color on hover

3. The social media icons should be more img-responsive

https://jsfiddle.net/onkkdef6/

HTML

  <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


            <div class="row">


              <div class="social">
                    <ul>
                    <li><a class="hexagon" href="#"><i class="fa fa-lg fa-linkedin"></i> </a> </li>
                    <li><a class="hexagon" href="#"><i class="fa fa-lg fa-twitter"></i> </a> </li>
                      <li><a class="hexagon" href="#"><i class="fa fa-lg fa-facebook"></i> </a> </li>
                    <li><a class="hexagon" href="#"><i class="fa fa-lg fa-yelp"></i></a></li>
                     <li><a class="hexagon" href="#"><i class="fa fa-lg fa-instagram"></i></a></li>
                    </ul>
                </div>


                      <div class="social">
                    <ul>
                    <li><a class="" href="#"><i class="fa fa-lg fa-linkedin"></i> </a> </li>
                    <li><a class="" href="#"><i class="fa fa-lg fa-twitter"></i> </a> </li>
                      <li><a class="" href="#"><i class="fa fa-lg fa-facebook"></i> </a> </li>
                    <li><a class="" href="#"><i class="fa fa-lg fa-yelp"></i></a></li>
                     <li><a class="" href="#"><i class="fa fa-lg fa-instagram"></i></a></li>
                    </ul>
                </div>


                </div>

CSS:

* { box-sizing: border-box; margin: 0; padding: 0; }



    .hexagon {
        position: relative;
        display: inline-block;
        overflow: hidden;
        margin: 0 8.5%;
        padding: 16%;
        transform: rotate(30deg) skewY(30deg) scaleX(.866); /* .866 = sqrt(3)/2 */
    }
    .hexagon:before{
        display: block;
        position: absolute; /* 86.6% = (sqrt(3)/2)*100% = .866*100% */
        top: 6.7%; right: 0; bottom: 6.7%; left: 0; /* 6.7% = (100% -86.6%)/2 */
        transform: scaleX(1.155) skewY(-30deg) rotate(-30deg); /* 1.155 = 2/sqrt(3) */
        background-color: rgba(30,144,255,.56);
        background-size: cover;
        content: '';
    }


        .social {
        margin: 0;
        padding: 0;
    }

    .social ul {
        margin: 0;
        padding: 5px;
    }

    .social ul li {
        margin: 5px;
        list-style: none outside none;
        display: inline-block;
    }


        .social i {
        width:80px;
        height: 80px;
        color: #FFF;
        background-color: #333;
        font-size: 42px;
        text-align:center;
        padding-top: 25px;

        transition: all ease 0.3s;
        -moz-transition: all ease 0.3s;
        -webkit-transition: all ease 0.3s;
        -o-transition: all ease 0.3s;
        -ms-transition: all ease 0.3s;
    }

    .social i:hover {

        text-decoration: none;
        transition: all ease 0.3s;
        -moz-transition: all ease 0.3s;
        -webkit-transition: all ease 0.3s;
        -o-transition: all ease 0.3s;
        -ms-transition: all ease 0.3s;
    }

        .social .fa-facebook:hover { /* round facebook icon*/
        background: #4060A5;
    }

    .social .fa-twitter:hover { /* round twitter icon*/
        background: #00ABE3;
    }

    .social .fa-yelp:hover { /* round google plus icon*/
        background: #e64522;
    }


    .social .fa-linkedin:hover { /* round linkedin icon*/
        background: #0094BC;
    }


    .social .fa-instagram:hover { /* round instagram icon*/
        background: #375989;
    }

Aucun commentaire:

Enregistrer un commentaire