I recently created one of my first hover effects using HTML and SASS. Since it is my first hover effect, I'm almost positive that is it horribly inefficient. I'm sure there's a way to do this effect using half the number of lines of code, but I can't figure out any ways to do it. The hover effect in question is for the "envelop" logo at the top left.
Here's a codepen of my page so far.
HTML
<header>
<div class="logocontainer">
<a href="#">
<h1 class="logoeffect-left">(</h1>
<h1 class="logo">envelop</h1>
<h1 class="logoeffect-right">)</h1>
</a>
</div>
</header>
<div class="wrapper">
<!-- remove the following line -->
<p>finish navbar, mobile version formatting is still fucked up....</p>
</div>
<footer></footer>
CSS (SASS)
$green: #4ede96;
$logoAnimationTime: 0.2s;
@mixin mLogoEffect_pre
{
color: white;
font-size: 48px;
display: inline-block;
transition: $logoAnimationTime 0 ease;
opacity: 0;
}
header
{
height: 100px;
width: 100%;
background: $green;
position: fixed;
top: 0;
@media only screen and (min-device-width : 320px) and (max-device-width : 480px)
{
height: 200px;
}
.logocontainer
{
@media only screen and (min-device-width : 320px) and (max-device-width : 480px)
{
margin-left: 35%;
display: block;
}
padding-top: 15px;
display: inline-block;
> a
{
text-decoration: none;
.logo
{
margin-top: 0;
font-family: 'Merriweather', serif;
font-size: 48px;
padding: 0 50px;
color: white;
display: inline-block;
}
.logoeffect-left
{
@include mLogoEffect_pre;
margin-left: 70px;
margin-right: -80px;
margin-top: 0;
margin-bottom: 0;
}
.logoeffect-right
{
@include mLogoEffect_pre;
margin-left: -80px;
margin-top: 0;
margin-bottom: 0;
}
&:hover
{
.logoeffect-left
{
transition: $logoAnimationTime 0 ease;
margin-right: -50px;
margin-left: 40px;
opacity: 1;
@media only screen and (min-device-width : 320px) and (max-device-width : 480px)
{
//dont change anything (hide animation)
@include mLogoEffect_pre;
margin-left: 70px;
margin-right: -80px;
margin-top: 0;
margin-bottom: 0;
}
}
.logoeffect-right
{
transition: $logoAnimationTime 0 ease;
margin-left: -50px;
opacity: 1;
@media only screen and (min-device-width : 320px) and (max-device-width : 480px)
{
//dont change anything (hide animation)
@include mLogoEffect_pre;
margin-left: -80px;
margin-top: 0;
margin-bottom: 0;
}
}
}
}
}
}