Image not showing animation after hover - html

I'm trying to show an animation whenever the cursor both hovers & leaves an image link, but for some reason whenever my cursor leaves the image, no animation occurs:
.soc {
display: block;
font-size: 0;
list-style: none;
margin: 0;
text-align: center;
}
.soc li {
display: inline-block;
margin: 12px;
margin: 1.2rem;
}
.soc a, .soc svg {
display: block;
}
.soc a {
position: relative;
height: 50px;
height: 5.0rem;
width: 50px;
width: 5.0rem;
}
.soc svg {
height: 100%;
width: 100%;
}
.soc em {
font-size: 14px;
line-height: 1.5;
margin-top: -0.75em;
position: absolute;
text-align: center;
top: 50%;
right: 0;
bottom: 0;
left: 0;
}
.icon-twitter:hover {
border-radius: 100%;
color: #fff;
fill: #fff;
-webkit-transform: scale(1.25);
transform: scale(1.25);
-webkit-transition: background-color 0.5s, -webkit-transform 0.5s ease-out;
transition: background-color 0.5s, -webkit-transform 0.5s ease-out;
transition: background-color 0.5s, transform 0.5s ease-out;
transition: background-color 0.5s, transform 0.5s ease-out, -webkit-transform 0.5s ease-out;
}
.icon-twitter
{
color: #000;
fill: #000;
}
.icon-twitter:hover {
background: #00aced;
}
<ul class="soc">
<li><a href="#" class="icon-twitter" title="Twitter">
<svg viewBox="0 0 512 512">
<path d="M419.6 168.6c-11.7 5.2-24.2 8.7-37.4 10.2 13.4-8.1 23.8-20.8 28.6-36 -12.6 7.5-26.5 12.9-41.3 15.8 -11.9-12.6-28.8-20.6-47.5-20.6 -42 0-72.9 39.2-63.4 79.9 -54.1-2.7-102.1-28.6-134.2-68 -17 29.2-8.8 67.5 20.1 86.9 -10.7-0.3-20.7-3.3-29.5-8.1 -0.7 30.2 20.9 58.4 52.2 64.6 -9.2 2.5-19.2 3.1-29.4 1.1 8.3 25.9 32.3 44.7 60.8 45.2 -27.4 21.4-61.8 31-96.4 27 28.8 18.5 63 29.2 99.8 29.2 120.8 0 189.1-102.1 185-193.6C399.9 193.1 410.9 181.7 419.6 168.6z"/>
</svg>
<!--[if lt IE 9]><em>Twitter</em><![endif]--></a></li>
</ul>

Put the transition property on the element itself, not on the hover state. Otherwise it won't affect the element when it is not hovered.
.soc {
display: block;
font-size: 0;
list-style: none;
margin: 0;
text-align: center;
}
.soc li {
display: inline-block;
margin: 12px;
margin: 1.2rem;
}
.soc a,
.soc svg {
display: block;
}
.soc a {
position: relative;
height: 50px;
height: 5.0rem;
width: 50px;
width: 5.0rem;
}
.soc svg {
height: 100%;
width: 100%;
}
.soc em {
font-size: 14px;
line-height: 1.5;
margin-top: -0.75em;
position: absolute;
text-align: center;
top: 50%;
right: 0;
bottom: 0;
left: 0;
}
.icon-twitter {
color: #000;
fill: #000;
border-radius: 100%;
transition: background-color 0.5s, -webkit-transform 0.5s ease-out;
transition: background-color 0.5s, transform 0.5s ease-out;
transition: background-color 0.5s, transform 0.5s ease-out, -webkit-transform 0.5s ease-out;
-webkit-transition: background-color 0.5s, -webkit-transform 0.5s ease-out;
}
.icon-twitter:hover {
color: #fff;
fill: #fff;
-webkit-transform: scale(1.25);
transform: scale(1.25);
background: #00aced;
}
<ul class="soc">
<li>
<a href="#" class="icon-twitter" title="Twitter">
<svg viewBox="0 0 512 512">
<path d="M419.6 168.6c-11.7 5.2-24.2 8.7-37.4 10.2 13.4-8.1 23.8-20.8 28.6-36 -12.6 7.5-26.5 12.9-41.3 15.8 -11.9-12.6-28.8-20.6-47.5-20.6 -42 0-72.9 39.2-63.4 79.9 -54.1-2.7-102.1-28.6-134.2-68 -17 29.2-8.8 67.5 20.1 86.9 -10.7-0.3-20.7-3.3-29.5-8.1 -0.7 30.2 20.9 58.4 52.2 64.6 -9.2 2.5-19.2 3.1-29.4 1.1 8.3 25.9 32.3 44.7 60.8 45.2 -27.4 21.4-61.8 31-96.4 27 28.8 18.5 63 29.2 99.8 29.2 120.8 0 189.1-102.1 185-193.6C399.9 193.1 410.9 181.7 419.6 168.6z"/>
</svg>
<!--[if lt IE 9]><em>Twitter</em><![endif]--></a>
</li>
</ul>

Related

CSS border colour and radius issues on links

I am having two issues with the following styled link.
There is a small, white border being displayed on the left and right sides of link on hover.
The ::before border radius is being applied during the transition on Webkit browsers. All other browsers are applying it before the transition.
I have tried adjusting z indexes for various elements, but this has had no effect on the small, white border issue.
I have tried applying border radius to a::before and a:hover::before to see if that would fix the issue in Webkit browsers, but no luck.
Any ideas on why these CSS issues are occurring?
body {
background-color: #1A1A1A;
padding: 3rem;
}
.cta {
display: inline-block;
text-decoration: none;
font-weight: 700;
font-size: 1.125rem;
font-family: "Barlow", sans-serif;
letter-spacing: -0.0225rem;
color: #D61E15;
}
.cta--pill {
padding: 0.625rem 1rem 0.625rem 1.5rem;
position: relative;
overflow: hidden;
background-color: #fff;
border: 0.03125rem solid #E6E6E6;
border-radius: 1.3125rem;
-webkit-transition: 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
}
.cta--pill::before {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
background-color: #D61E15;
border: 0.03125rem solid #D61E15;
border-radius: 1.3125rem;
-webkit-transform: translateX(-100%);
-moz-transform: translateX(-100%);
transform: translateX(-100%);
-webkit-transition: transform 0.35s ease-in-out;
-moz-transition: transform 0.35s ease-in-out;
transition: transform 0.35s ease-in-out;
}
.cta--pill .cta-text {
padding-right: 2.25rem;
position: relative;
z-index: 2;
}
.cta--pill .cta-arrow {
display: flex;
justify-content: center;
align-items: center;
width: 1.75rem;
height: 1.75rem;
position: absolute;
top: 0.4375rem;
right: 0.5rem;
z-index: 2;
background-color: #D61E15;
box-shadow: 0 2px 5px 0 rgba(176, 25, 17, 0.41);
border-radius: 100%;
border: 0.03125rem solid transparent;
-webkit-transition: 0.4s ease-in-out;
-moz-transition: 0.4s ease-in-out;
transition: 0.4s ease-in-out;
}
.cta--pill:hover {
border-color: #D61E15;
box-shadow: 0 4px 10px 0 rgba(176, 25, 17, 0.41);
color: #fff;
}
.cta--pill:hover::before {
transform: translateX(0);
}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght#700&display=swap" rel="stylesheet">
<a class="cta cta--pill cta--no-shadow" href="#" title="View all services">
<span class="cta-text">All Services</span>
<span class="cta-arrow">
<svg role="img" class="arrow arrow--right" width="14" height="14" xmlns="http://www.w3.org/2000/svg">
<path d="M6.02 1.183l.658-.658a.708.708 0 0 1 1.004 0l5.761 5.758a.708.708 0 0 1 0 1.004l-5.76 5.761a.708.708 0 0 1-1.005 0l-.658-.658a.712.712 0 0 1 .012-1.016l3.57-3.402H1.087a.71.71 0 0 1-.711-.711v-.949a.71.71 0 0 1 .71-.711h8.518L6.032 2.199a.707.707 0 0 1-.012-1.016z" fill="#FFF"></path>
</svg>
</span>
</a>
You may also slide background-gradients via background-position.
possible example:
body {
background-color: #1A1A1A;
padding: 3rem;
}
.cta {
display: inline-block;
text-decoration: none;
font-weight: 700;
font-size: 1.125rem;
font-family: "Barlow", sans-serif;
letter-spacing: -0.0225rem;
color: #D61E15;
}
.cta--pill {
padding: 0.625rem 1rem 0.625rem 1.5rem;
position: relative;
overflow: hidden;
background-image: radial-gradient(circle at 75% 50%, #D61E15 1.3rem, transparent 1.35rem), linear-gradient(0, #D61E15, #D61E15);
background-repeat: no-repeat;
background-size: 200% 200%;
background-position: 180% 50%, 220% 0;
background-color: #fff;
border: 0.03125rem solid #E6E6E6;
border-radius: 1.3125rem;
-webkit-transition: 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
}
.cta--pill:hover {
background-position: 50% 50%, 100% 0;
}
.cta--pill .cta-text {
padding-right: 2.25rem;
position: relative;
z-index: 2;
}
.cta--pill .cta-arrow {
display: flex;
justify-content: center;
align-items: center;
width: 1.75rem;
height: 1.75rem;
position: absolute;
top: 0.4375rem;
right: 0.5rem;
z-index: 2;
background-color: #D61E15;
box-shadow: 0 2px 5px 0 rgba(176, 25, 17, 0.41);
border-radius: 100%;
border: 0.03125rem solid transparent;
-webkit-transition: 0.4s ease-in-out;
-moz-transition: 0.4s ease-in-out;
transition: 0.4s ease-in-out;
}
.cta--pill:hover {
border-color: #D61E15;
box-shadow: 0 4px 10px 0 rgba(176, 25, 17, 0.41);
color: #fff;
}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght#700&display=swap" rel="stylesheet">
<a class="cta cta--pill cta--no-shadow" href="#" title="View all services">
<span class="cta-text">All Services</span>
<span class="cta-arrow">
<svg role="img" class="arrow arrow--right" width="14" height="14" xmlns="http://www.w3.org/2000/svg">
<path d="M6.02 1.183l.658-.658a.708.708 0 0 1 1.004 0l5.761 5.758a.708.708 0 0 1 0 1.004l-5.76 5.761a.708.708 0 0 1-1.005 0l-.658-.658a.712.712 0 0 1 .012-1.016l3.57-3.402H1.087a.71.71 0 0 1-.711-.711v-.949a.71.71 0 0 1 .71-.711h8.518L6.032 2.199a.707.707 0 0 1-.012-1.016z" fill="#FFF"></path>
</svg>
</span>
</a>
You can try adding a negative inset to the ::before selector.
body {
background-color: #1A1A1A;
padding: 3rem;
}
.cta {
display: inline-block;
text-decoration: none;
font-weight: 700;
font-size: 1.125rem;
font-family: "Barlow", sans-serif;
letter-spacing: -0.0225rem;
color: #D61E15;
}
.cta--pill {
padding: 0.625rem 1rem 0.625rem 1.5rem;
position: relative;
overflow: hidden;
background-color: #fff;
border: 0.03125rem solid #E6E6E6;
border-radius: 1.3125rem;
-webkit-transition: 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
}
.cta--pill::before {
content: "";
position: absolute;
top: -1px;
right: -1px;
bottom: -1px;
left: -1px;
z-index: 1;
background-color: #D61E15;
border: 0.03125rem solid #D61E15;
border-radius: 1.3125rem;
-webkit-transform: translateX(-100%);
-moz-transform: translateX(-100%);
transform: translateX(-100%);
-webkit-transition: transform 0.35s ease-in-out;
-moz-transition: transform 0.35s ease-in-out;
transition: transform 0.35s ease-in-out;
}
.cta--pill .cta-text {
padding-right: 2.25rem;
position: relative;
z-index: 2;
}
.cta--pill .cta-arrow {
display: flex;
justify-content: center;
align-items: center;
width: 1.75rem;
height: 1.75rem;
position: absolute;
top: 0.4375rem;
right: 0.5rem;
z-index: 2;
background-color: #D61E15;
box-shadow: 0 2px 5px 0 rgba(176, 25, 17, 0.41);
border-radius: 100%;
border: 0.03125rem solid transparent;
-webkit-transition: 0.4s ease-in-out;
-moz-transition: 0.4s ease-in-out;
transition: 0.4s ease-in-out;
}
.cta--pill:hover {
border-color: #D61E15;
box-shadow: 0 4px 10px 0 rgba(176, 25, 17, 0.41);
color: #fff;
}
.cta--pill:hover::before {
transform: translateX(0);
}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght#700&display=swap" rel="stylesheet">
<a class="cta cta--pill cta--no-shadow" href="#" title="View all services">
<span class="cta-text">All Services</span>
<span class="cta-arrow">
<svg role="img" class="arrow arrow--right" width="14" height="14" xmlns="http://www.w3.org/2000/svg">
<path d="M6.02 1.183l.658-.658a.708.708 0 0 1 1.004 0l5.761 5.758a.708.708 0 0 1 0 1.004l-5.76 5.761a.708.708 0 0 1-1.005 0l-.658-.658a.712.712 0 0 1 .012-1.016l3.57-3.402H1.087a.71.71 0 0 1-.711-.711v-.949a.71.71 0 0 1 .71-.711h8.518L6.032 2.199a.707.707 0 0 1-.012-1.016z" fill="#FFF"></path>
</svg>
</span>
</a>
Adding background-color: #D61E15; inside .cta--pill:hover will solve your white border problem.
body {
background-color: #1A1A1A;
padding: 3rem;
}
.cta {
display: inline-block;
text-decoration: none;
font-weight: 700;
font-size: 1.125rem;
font-family: "Barlow", sans-serif;
letter-spacing: -0.0225rem;
color: #D61E15;
}
.cta--pill {
padding: 0.625rem 1rem 0.625rem 1.5rem;
position: relative;
overflow: hidden;
background-color: #fff;
border: 0.03125rem solid #E6E6E6;
border-radius: 1.3125rem;
-webkit-transition: 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
}
.cta--pill::before {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
background-color: #D61E15;
border: 0.03125rem solid #D61E15;
border-radius: 1.3125rem;
-webkit-transform: translateX(-100%);
-moz-transform: translateX(-100%);
transform: translateX(-100%);
-webkit-transition: transform 0.35s ease-in-out;
-moz-transition: transform 0.35s ease-in-out;
transition: transform 0.35s ease-in-out;
}
.cta--pill .cta-text {
padding-right: 2.25rem;
position: relative;
z-index: 2;
}
.cta--pill .cta-arrow {
display: flex;
justify-content: center;
align-items: center;
width: 1.75rem;
height: 1.75rem;
position: absolute;
top: 0.4375rem;
right: 0.5rem;
z-index: 2;
background-color: #D61E15;
box-shadow: 0 2px 5px 0 rgba(176, 25, 17, 0.41);
border-radius: 100%;
border: 0.03125rem solid transparent;
-webkit-transition: 0.4s ease-in-out;
-moz-transition: 0.4s ease-in-out;
transition: 0.4s ease-in-out;
}
.cta--pill:hover {
border-color: #D61E15;
background-color: #D61E15;
box-shadow: 0 4px 10px 0 rgba(176, 25, 17, 0.41);
color: #fff;
}
.cta--pill:hover::before {
transform: translateX(0);
}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght#700&display=swap" rel="stylesheet">
<a class="cta cta--pill cta--no-shadow" href="#" title="View all services">
<span class="cta-text">All Services</span>
<span class="cta-arrow">
<svg role="img" class="arrow arrow--right" width="14" height="14" xmlns="http://www.w3.org/2000/svg">
<path d="M6.02 1.183l.658-.658a.708.708 0 0 1 1.004 0l5.761 5.758a.708.708 0 0 1 0 1.004l-5.76 5.761a.708.708 0 0 1-1.005 0l-.658-.658a.712.712 0 0 1 .012-1.016l3.57-3.402H1.087a.71.71 0 0 1-.711-.711v-.949a.71.71 0 0 1 .71-.711h8.518L6.032 2.199a.707.707 0 0 1-.012-1.016z" fill="#FFF"></path>
</svg>
</span>
</a>

Text over image css with overlay effect

I tried to put some contents over an image with some overlay effects, but it does not shows output as my needs. Also I don't know how to do overlay effects anyone can help me please.
.destination {
padding: 20px;
-ms-transform: translate(0, 0);
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
transition: all .5s ease;
-ms-transition: all .5s ease;
-webkit-transition: all .5s ease;
}
.destination h3 {
font-size: 25px;
color: #fff;
line-height: 20px;
text-transform: uppercase;
margin-bottom: 10px;
}
.destination span {
display: block;
font-size: 15px;
color: #fff;
line-height: 16px;
}
.overlay-leftTop {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 9;
transition: all .3s ease;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
}
.destinationmask {
width: 100%;
height: 100%;
z-index: 5;
opacity: 0.4;
filter: alpha(opacity=50);
background: #000;
}
<img src="https://image.ibb.co/evyyfm/mu.jpg" alt="img01"/>
<a href="" class="overlay-leftTop">
<div class="table-display">
<div class="table-cell table-cell-bottom">
<div class="destination">
<h3>TEST</h3>
<span>Check,check1,check2</span>
</div>
</div>
</div>
Actually I need something like this
You should use background-image CSS property instead of <img> tag. And for effects use pseudo elements like :before.
Have a look at the snippet below:
.destination {
padding: 20px;
-ms-transform: translate(0, 0);
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
transition: all .5s ease;
-ms-transition: all .5s ease;
-webkit-transition: all .5s ease;
}
.destination h3 {
font-size: 25px;
color: #fff;
line-height: 20px;
text-transform: uppercase;
margin-bottom: 10px;
}
.destination span {
display: block;
font-size: 15px;
color: #fff;
line-height: 16px;
}
.overlay-leftTop {
display: block;
position: relative;
text-decoration: none;
width: 300px;
height: 300px;
z-index: 9;
transition: all .3s ease;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
}
.overlay-leftTop:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 1;
background: rgba(0,0,0,0.3);
transition: all .3s ease;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
}
.overlay-leftTop:hover {
text-decoration: none;
}
.overlay-leftTop:hover:before {
background: rgba(0,0,0,0.5);
}
.destinationmask {
width: 100%;
height: 100%;
z-index: 5;
opacity: 0.4;
filter: alpha(opacity=50);
background: #000;
}
<a href="" class="overlay-leftTop" style="background-image: url('https://image.ibb.co/evyyfm/mu.jpg');">
<div class="table-display">
<div class="table-cell table-cell-bottom">
<div class="destination">
<h3>TEST</h3>
<span>Check,check1,check2</span>
</div>
</div>
</div>
</a>
Hope this helps!
I think this is what u want.
.destination {
padding: 20px;
-ms-transform: translate(0, 0);
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
transition: all .5s ease;
-ms-transition: all .5s ease;
-webkit-transition: all .5s ease;
}
.destination h3 {
font-size: 25px;
color: #fff;
line-height: 20px;
text-transform: uppercase;
margin-bottom: 10px;
}
.destination span {
display: block;
font-size: 15px;
color: #fff;
line-height: 16px;
}
.overlay-leftTop {
display: block;
position: relative;
text-decoration: none;
width: 300px;
height: 300px;
z-index: 9;
transition: all .3s ease;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
}
.overlay-leftTop:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 1;
background: rgba(0,0,0,0.3);
transition: all .3s ease;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
}
.overlay-leftTop:hover {
text-decoration: none;
}
.overlay-leftTop:hover:before {
background: rgba(0,0,0,0.5);
}
.destinationmask {
width: 100%;
height: 100%;
z-index: 5;
opacity: 0.4;
filter: alpha(opacity=50);
background: #000;
}
.view-btn{
position: absolute;
top: 180px;
font-size: 16px !important;
border: 2px solid #fff;
display: inline-block !important;
text-align: center;
padding: 10px 15px;
opacity: 0;
transition:all 350ms ease 0s;
}
.overlay-leftTop:hover .view-btn{
opacity:1;
}
<a href="" class="overlay-leftTop" style="background-image: url('https://image.ibb.co/evyyfm/mu.jpg');">
<div class="table-display">
<div class="table-cell table-cell-bottom">
<div class="destination">
<h3>TEST</h3>
<span>Check,check1,check2</span>
<span class="view-btn">View More</Span>
</div>
</div>
</div>
</a>
Please try this. I have added some css:
.img-wrap {
display: inline-block;
position: relative;
width: 386px;
}
.img-box:before {
position: absolute;
content: "";
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.4);
transform:scale(0);
transition: all .5s ease;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
}
.img-wrap:hover .img-box:before {
transform:scale(1);
}
.img-wrap:hover .overlay-leftTop{
opacity:1;
}
img {
height: auto;
max-height: 100%;
max-width: 100%;
width: auto;
display: block;
}
.destination {
padding: 20px;
-ms-transform: translate(0, 0);
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
transition: all .5s ease;
-ms-transition: all .5s ease;
-webkit-transition: all .5s ease;
}
.destination h3 {
font-size: 25px;
color: #fff;
line-height: 20px;
text-transform: uppercase;
margin-bottom: 10px;
}
.destination span {
display: block;
font-size: 15px;
color: #fff;
line-height: 16px;
}
.overlay-leftTop {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity:0;
transition: all .5s ease;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
}
.img-wrap {
display: inline-block;
position: relative;
width: 386px;
}
.img-box:before {
position: absolute;
content: "";
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.4);
transform:scale(0);
transition: all .5s ease;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
}
.img-wrap:hover .img-box:before {
transform:scale(1);
}
.img-wrap:hover .overlay-leftTop{
opacity:1;
}
img {
height: auto;
max-height: 100%;
max-width: 100%;
width: auto;
display: block;
}
<div class="img-wrap">
<div class="img-box">
<img src="https://image.ibb.co/evyyfm/mu.jpg" alt="img01"/>
</div>
<a href="" class="overlay-leftTop">
<div class="table-display">
<div class="table-cell table-cell-bottom">
<div class="destination">
<h3>TEST</h3>
<span>Check,check1,check2</span>
</div>
</div>
</div>
</a>
</div>

Menu navigation bar | position issue

I have 2 problems with my navbar design.
First, the navbar stays at the top, even if I scroll down. I think it's due to the absolute position I gave to the <nav>.
Last but not least, when I roll out the menu (the height of my windows is short, like with a smartphone in landscape mode) and then I scroll down, there is no more background-color. I know this is due to "height: 100%;" (line 137 of CSS doc). But when I remove "height: 100%;", I haven't the transition that I had with "height: 100%;" declaration. How to resolve this issue?
Thanks a lot!
jQuery(document).ready(function(){
jQuery('#nav-burger').click(function() {
jQuery('.list-shown, .list-hidden').each(function() {
jQuery(this).toggleClass('list-shown').toggleClass('list-hidden');
});
});
});
#import url(https://fonts.googleapis.com/css?family=Raleway:400,300,200,100,500,600,700,800,900);
#import url(http://fonts.googleapis.com/css?family=Titillium+Web);
#viewport { /* peu supporté / ne remplace pas encore la balise <meta> */
width: device-width; /* largeur du viewport */
zoom: 1; /* zoom initial à 1.0 */
}
*, *::before, *::after {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow-x: hidden;
text-rendering: optimizelegibility;
}
img {
width: 100%;
}
nav {
margin:0;
background: rgba(0,0,0,0.7);
font-family:"Titillium Web", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
font-weight: 600;
}
#navigationgenerale {
display: block;
position: absolute;
top: 0;
right: 0;
left: 0;
z-index: 10;
}
#navigationgenerale li {
list-style: none;
}
#navigationgenerale .nav-content {
margin:0 auto;
max-width: 1000px;
}
#navigationgenerale .nav-content ul {
margin: 0;
padding: .5em 0px;
line-height: 30px;
width: auto;
text-align: justify;
display: flex;
}
#navigationgenerale .nav-content .nav-header {
display: none;
}
#navigationgenerale .nav-content .nav-item {
display: inline-block;
position: relative;
height: 30px;
vertical-align: middle;
}
#navigationgenerale .nav-content .nav-item a {
text-decoration: none;
font-size: 22px;
}
#navigationgenerale.list-hidden .nav-content .nav-item a {
color: #ececec;
}
#navigationgenerale.list-shown .nav-content .nav-item a {
color: #191919;
}
#navigationgenerale .nav-content .nav-header {
justify-content: space-between;
}
#navigationgenerale .nav-content .nav-list {
justify-content: space-around;
}
#navigationgenerale.list-shown .nav-content ul.nav-list {
display: block;
padding: 5% 10%;
}
#navigationgenerale.list-shown .nav-content .nav-list li {
display: list-item;
border-bottom: #555 1px dotted;
padding: 15px 5px;
height: auto; /* important */
}
#navigationgenerale .nav-content .icon a {
display: inline-block;
overflow: hidden;
text-indent: 160%;
white-space: nowrap;
}
#navigationgenerale.list-hidden .nav-content .icon.nav-accueil a {
background: url("//alexandredomain.ovh/beta/sprite.svg#logo-ececec") 50% 50% no-repeat;
background-size: 50px;
transition: background 0.5s 0s ease-in;
}
#navigationgenerale.list-shown .nav-content .icon.nav-accueil a {
background: url("//alexandredomain.ovh/beta/sprite.svg#logo-191919") 50% 50% no-repeat;
background-size: 50px;
}
#navigationgenerale .nav-content .icon.nav-contact a {
background: url("//alexandredomain.ovh/beta/sprite.svg#letter-ececec") 50% 50% no-repeat;
background-size: 35px;
width: 50px;
height: auto;
}
#media screen and (max-width: 1760px) {
#navigationgenerale .nav-content ul.nav-header {
display: flex;
}
#navigationgenerale .nav-content .nav-list li.nav-accueil {
display: none;
}
#navigationgenerale.list-hidden .nav-content .nav-list {
display: none;
}
#navigationgenerale.list-shown {
background-color: #ececec;
transition: height 1s 1s ease-in-out, background-color .5s .5s linear;
color: #191919;
overflow-y: visible;
height: 100%;
}
#navigationgenerale.list-hidden {
height: 66px;
transition: height 1s 0s ease-in-out, background-color .5s 0s linear;
}
#navigationgenerale.list-shown .nav-content .nav-header .nav-contact a {
transform: translateY(-200%) translateX(200%) ;
transition: transform 0.5s .5s ease-in-out;
}
#navigationgenerale.list-shown .nav-content .nav-list ul {
display: block !important;
}
#navigationgenerale .nav-content ul {
margin: 10px 15px;
}
}
.list-shown line.ligne-haut {
stroke: #191919;
transform: translateY(28px) rotate(-405deg);
transform-origin: 50%;
transition: all 0.5s 0.2s cubic-bezier(0.4, 0.01, 0.165, 0.99);
}
.list-hidden line.ligne-haut {
transform: translateY(0px) rotate(0deg);
transform-origin: 50%;
transition: all 0.5s 0.2s cubic-bezier(0.4, 0.01, 0.165, 0.99);
}
.list-shown line.ligne-milieu {
opacity: 0;
transition: opacity 0.3s linear;
}
.list-hidden line.ligne-milieu {
opacity: 1;
transition: opacity 0.3s 0.5s linear;
}
.list-shown line.ligne-bas {
stroke: #191919;
transform: translateY(-28px) rotate(405deg);
transform-origin: 50%;
transition: all 0.5s 0.2s cubic-bezier(0.4, 0.01, 0.165, 0.99);
}
.list-hidden line.ligne-bas {
transform: translateY(0px) rotate(0deg);
transform-origin: 50%;
transition: all 0.5s 0.2s cubic-bezier(0.4, 0.01, 0.165, 0.99);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<nav id="navigationgenerale" class="list-hidden" lang="fr-FR" aria-label="Navigation générale" role="navigation">
<div class="nav-content">
<ul class="nav-header">
<li class="nav-item nav-menu">
<svg id="nav-burger" x="0px" y="0px" height="35px" width="35px" viewBox="0 0 96 96">
<line class="ligne-haut" x1="12" y1="20" x2="84" y2="20" stroke="#ececec" stroke-width="8" stroke-linecap="round"></line>
<line class="ligne-milieu" x1="12" y1="48" x2="84" y2="48" stroke="#ececec" stroke-width="8" stroke-linecap="round" stroke-opacity="1"></line>
<line class="ligne-bas" x1="12" y1="76" x2="84" y2="76" stroke="#ececec" stroke-width="8" stroke-linecap="round"></line>
</svg>
</li>
<li class="nav-item nav-accueil icon">Accueil</li>
<li class="nav-item nav-contact icon">Contact</li>
</ul>
<ul class="nav-list">
<li class="nav-item nav-accueil icon">Accueil</li>
<li class="nav-item nav-parcours">Parcours</li>
<li class="nav-item nav-experience">Expérience</li>
<li class="nav-item nav-projet">Projet</li>
<li class="nav-item nav-loisirs">Loisirs</li>
<li class="nav-item nav-contact">Contact</li>
</ul>
</div>
</nav>
<div style="margin-top: 450px; font-family: Raleway; font-weight: 500; font-size: 60px;"> Test </div>
</body>
To your 1. question:
Change the postion:absolute to postion:relative #navigationgenerale block.
question:
Instead of height 100% change it to an specific value like 460px.

CSS Onmouseexit Fade out

I am trying to replicate (in my own way) the facebook change image on hover element.
But I am trying to make it fade out, which I can't seem to do... I wonder if anyone can help me.
Any help will be appreciated. Preferably I would want to do this without jQuery or JS.
So far I have this (on JSfiddle: http://jsfiddle.net/Blue_EyesWhiteDragon/p05e8n56):
HTML:
<span class="right">
<div class="ui-root">
<img class="profimg" id="profileimg" src="http://i.imgur.com/CabNLvV.jpg" width="130" height="130">
<a href="#" class="ui-link" role="button">
<div class="ui-popover">
<img class="ui-dimg" src="https://fbstatic-a.akamaihd.net/rsrc.php/v2/yx/r/PuyR8Oy6W1C.png" alt="" width="32" height="32">
<div class="ui-text">Update Image</div>7
</div>
</a>
</div>
</span>
CSS:
.ui-root{
cursor: pointer;
height: 130px;
width: 130px;
}
.ui-root a:link, a:visited {
text-decoration: none;
}
.ui-link{
display: block;
text-align: center;
position: relative;
visibility: hidden;
top: -44px;
width: 130px;
height: 40px;
background-color: rgba(0, 0, 0, 68);
color: white;
opacity: 0;
-webkit-transition: padding 2s, //Contains Hover off | Chrome & Safari
-moz-transition: padding 2s; //Mozilla
-o-transition: padding 2s; //Opera
transition: padding 2s; //IE
}
.ui-img:hover + .ui-link{
zoom: 1;
opacity: 1;
visibility: visible;
background-color: rgba(0, 0, 0, 0.68);
border-radius: 1px;
-webkit-transition: border-radius 2s, background-color 300ms linear, opacity 300ms linear; //Contains Hover on | Chrome & Safari
-moz-transition: border-radius 2s, background-color 300ms linear, opacity 300ms linear; //Mozilla
-o-transition: border-radius 2s, background-color 300ms linear, opacity 300ms linear; //Opera
transition: border-radius 2s, background-color 300ms linear, opacity 300ms linear; //IE
}
.ui-link:hover{
zoom: 1;
opacity: 1;
visibility: visible;
background-color: rgba(0, 0, 0, 0.87);
border-radius: 1px;
-webkit-transition: padding 2s, background-color 300ms linear, opacity 300ms linear; //Contains Hover off | Chrome & Safari
-moz-transition: padding 2s, background-color 300ms linear, opacity 300ms linear; //Mozilla
-o-transition: padding 2s, background-color 300ms linear, opacity 300ms linear; //Opera
transition: padding 2s, background-color 300ms linear, opacity 300ms linear; //IE
}
.ui-dimg{
display: block;
text-align: left;
position: absolute;
top: 2px;
left: 2px;
}
.ui-text{
display: block;
text-align: left;
width: 108px;
padding-bottom: 10px;
padding-left: 40px;
padding-right: 12px;
padding-top: 10px;
top: 2px;
left: -2px;
position: absolute;
font-weight: 700;
font-size: 12px;
font-family: Helvetica, Arial, 'lucida grande',tahoma,verdana,arial,sans-serif;
word-wrap: break-word;
}
.ui-popover{
position: absolute;
z-index: 5;
left: 0px;
}
Are you trying to do something like this
.ui-root {
cursor: pointer;
height: 130px;
width: 130px;
}
.ui-root a:link,
a:visited {
text-decoration: none;
}
.ui-link {
display: block;
text-align: center;
position: relative;
top: -44px;
width: 130px;
height: 40px;
background-color: rgba(0, 0, 0, 68);
color: white;
opacity: 0;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
.ui-img:hover + .ui-link {
zoom: 1;
opacity: 1;
background-color: rgba(0, 0, 0, 0.68);
border-radius: 1px;
}
.ui-link:hover {
zoom: 1;
opacity: 1;
visibility: visible;
background-color: rgba(0, 0, 0, 0.87);
border-radius: 1px;
}
.ui-dimg {
display: block;
text-align: left;
position: absolute;
top: 2px;
left: 2px;
}
.ui-text {
display: block;
text-align: left;
width: 108px;
padding-bottom: 10px;
padding-left: 40px;
padding-right: 12px;
padding-top: 10px;
top: 2px;
left: -2px;
position: absolute;
font-weight: 700;
font-size: 12px;
font-family: Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif;
word-wrap: break-word;
}
.ui-popover {
position: absolute;
z-index: 5;
left: 0px;
}
<span class="right">
<div class="ui-root">
<a href="#" class="ui-img">
<img class="profimg" id="profileimg" src="http://i.imgur.com/CabNLvV.jpg" width="130" height="130"></a>
<a href="#" class="ui-link" role="button">
<div class="ui-popover">
<img class="ui-dimg" src="https://fbstatic-a.akamaihd.net/rsrc.php/v2/yx/r/PuyR8Oy6W1C.png" alt="" width="32" height="32" />
<div class="ui-text">Update Image</div>
</div>
</a>
</div>
</span>

Making off-canvas sliding menu with css

I want to make a sliding menu using solely CSS. The menu will reveal a list of items and a close button inside it. I currently have an anchor tag on my homepage that is styled correctly, but it does not do anything when clicked.
HTML:
<body class="homepage body-push">
<!-- Menu -->
<nav class="menu" id="theMenu">
<div class="menu-wrap">
<h1 class="logo">Focus</h1>
<i class="icon-remove menu-close"></i>
Home
Services
Process
Portfolio
About
Contact
<i class="icon-facebook"></i>
<i class="icon-twitter"></i>
<i class="icon-dribbble"></i>
<i class="icon-envelope"></i>
</div>
<!-- Menu button -->
<div id="menuToggle"><i class="icon-reorder"></i></div>
</nav>
</body>
CSS:
.menu {
position: fixed;
right: -200px;
width: 260px;
height: 100%;
top: 0;
z-index: 10;
text-align: left;
}
.menu.menu-open {
right: 0px;
}
.menu-wrap {
position: absolute;
top: 0;
left: 60px;
background: #1a1a1a;
width: 200px;
height: 100%;
}
.menu a {
margin-left: 20px;
color: #808080;
display: block;
font-size: 12px;
font-weight: 700;
line-height: 40px;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.menu a:hover {
color: #ffffff;
}
.menu a:active {
color: #ffffff;
}
.menu a > i {
float: left;
display: inline-block;
vertical-align: middle;
text-align: left;
width: 25px;
font-size: 14px;
line-height: 40px;
margin: 25px 2px;
}
.menu-close {
cursor: pointer;
display: block;
position: absolute;
font-size: 14px;
color: #808080;
width: 40px;
height: 40px;
line-height: 40px;
top: 20px;
right: 5px;
-webkit-transition: all .1s ease-in-out;
-moz-transition: all .1s ease-in-out;
-ms-transition: all .1s ease-in-out;
-o-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
.menu-close:hover {
color: #ffffff;
-webkit-transition: all .1s ease-in-out;
-moz-transition: all .1s ease-in-out;
-ms-transition: all .1s ease-in-out;
-o-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
/* Push the body after clicking the menu button */
.body-push {
overflow-x: hidden;
position: relative;
left: 0;
}
.body-push-toright {
left: 200px;
}
.body-push-toleft {
left: -200px;
}
.menu,
.body-push {
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
}
#menuToggle {
position: absolute;
top: 20px;
left: 0;
z-index: 11;
display: block;
text-align: center;
font-size: 14px;
color: #ffffff;
width: 40px;
height: 40px;
line-height: 40px;
cursor: pointer;
background: rgba(0,0,0,0.25);
-webkit-transition: all .1s ease-in-out;
-moz-transition: all .1s ease-in-out;
-ms-transition: all .1s ease-in-out;
-o-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
#menuToggle:hover {
color: #ffffff;
background: rgba(0,0,0,0.2);
-webkit-transition: all .1s ease-in-out;
-moz-transition: all .1s ease-in-out;
-ms-transition: all .1s ease-in-out;
-o-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
UPDATE: I finally found a way to get it working.
HTML:
<!-- Menu -->
<nav class="menu" id="theMenu">
<div class="menu-wrap">
<h1 class="logo">Menu</h1>
<i class="icon-remove menu-close"></i>
Home
Services
Process
Portfolio
About
Contact
<i class="icon-facebook"></i>
<i class="icon-twitter"></i>
<i class="icon-dribbble"></i>
<i class="icon-envelope"></i>
</div>
<!-- Menu button -->
<div id="menuToggle"><i class="icon-reorder"></i></div>
</nav>
CSS:
.menu {
position: fixed;
right: -200px;
width: 260px;
height: 100%;
top: 0;
z-index: 10;
text-align: left;
}
.menu.menu-open {
right: 0px;
}
.menu-wrap {
position: absolute;
top: 0;
left: 60px;
background: #1a1a1a;
width: 200px;
height: 100%;
}
.menu h1.logo a {
font-family: 'Raleway', Helvetica, Arial, sans-serif;
font-size: 16px;
font-weight: 800;
letter-spacing: 0.15em;
line-height: 40px;
text-transform: uppercase;
color: #ffffff;
margin-top: 20px;
}
.menu h1.logo a:hover {
color: #f85c37;
}
.menu img.logo {
margin: 20px 0;
max-width: 160px;
}
.menu a {
margin-left: 20px;
color: #808080;
display: block;
font-size: 12px;
font-weight: 700;
line-height: 40px;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.menu a:hover {
color: #ffffff;
}
.menu a:active {
color: #ffffff;
}
.menu a > i {
float: left;
display: inline-block;
vertical-align: middle;
text-align: left;
width: 25px;
font-size: 14px;
line-height: 40px;
margin: 25px 2px;
}
.menu-close {
cursor: pointer;
display: block;
position: absolute;
font-size: 14px;
color: #808080;
width: 40px;
height: 40px;
line-height: 40px;
top: 20px;
right: 5px;
-webkit-transition: all .1s ease-in-out;
-moz-transition: all .1s ease-in-out;
-ms-transition: all .1s ease-in-out;
-o-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
.menu-close:hover {
color: #ffffff;
-webkit-transition: all .1s ease-in-out;
-moz-transition: all .1s ease-in-out;
-ms-transition: all .1s ease-in-out;
-o-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
/* Push the body after clicking the menu button */
.body-push {
overflow-x: hidden;
position: relative;
left: 0;
}
.body-push-toright {
left: 200px;
}
.body-push-toleft {
left: -200px;
}
.menu,
.body-push {
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
}
#menuToggle {
position: absolute;
top: 20px;
left: 0;
z-index: 11;
display: block;
text-align: center;
font-size: 14px;
color: #ffffff;
width: 40px;
height: 40px;
line-height: 40px;
cursor: pointer;
background: rgba(0,0,0,0.25);
-webkit-transition: all .1s ease-in-out;
-moz-transition: all .1s ease-in-out;
-ms-transition: all .1s ease-in-out;
-o-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
#menuToggle:hover {
color: #ffffff;
background: rgba(0,0,0,0.2);
-webkit-transition: all .1s ease-in-out;
-moz-transition: all .1s ease-in-out;
-ms-transition: all .1s ease-in-out;
-o-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
Javascript:
// Menu settings
$('#menuToggle, .menu-close').on('click', function(){
$('#menuToggle').toggleClass('active');
$('body').toggleClass('body-push-toleft');
$('#theMenu').toggleClass('menu-open');
});
// Scrollable menu on small devices
$(window).bind("load resize", function(){
if($(window).height() < 400){
$(".menu").css("overflow-y","scroll");
}
else {
$(".menu").css("overflow-y","hidden");
}
});
I would recommend reading this: http://www.sitepoint.com/css3-sliding-menu/
If the article is TL;DR then use
/* Revealing 3D Menu CSS */
body
{
font-family: sans-serif;
font-size: 100%;
padding: 0;
margin: 0;
color: #333;
background-color: #221;
}
/* main page */
article
{
position: fixed;
width: 70%;
left: 0;
top: 0;
right: 0;
bottom: 0;
padding: 30px 15%;
background-color: #fff;
overflow: auto;
z-index: 0;
-webkit-transform-origin: 0 50%;
-moz-transform-origin: 0 50%;
-ms-transform-origin: 0 50%;
-o-transform-origin: 0 50%;
transform-origin: 0 50%;
}
article:after
{
position: absolute;
content: ' ';
left: 100%;
top: 0;
right: 0;
bottom: 0;
background-image: -webkit-linear-gradient(right, rgba(0,0,0,0.2) 0%, transparent 100%);
background-image: -moz-linear-gradient(right, rgba(0,0,0,0.2) 0%, transparent 100%);
background-image: -ms-linear-gradient(right, rgba(0,0,0,0.2) 0%, transparent 100%);
background-image: -o-linear-gradient(right, rgba(0,0,0,0.2) 0%, transparent 100%);
background-image: linear-gradient(right, rgba(0,0,0,0.2) 0%, transparent 100%);
pointer-events: none;
}
/* navigation */
nav
{
position: fixed;
left: -16em;
top: 0;
bottom: 0;
background-color: #654;
border-right: 50px solid #765;
box-shadow: 4px 0 5px rgba(0,0,0,0.2);
z-index: 1;
cursor: pointer;
}
nav:after
{
position: absolute;
content: ' ';
width: 0;
height: 0;
right: -70px;
top: 50%;
border-width: 15px 10px;
border-style: solid;
border-color: transparent transparent transparent #765;
}
nav ul
{
width: 14em;
list-style-type: none;
margin: 0;
padding: 1em;
}
nav a:link, nav a:visited
{
display: block;
width: 100%;
font-weight: bold;
line-height: 2.5em;
text-indent: 10px;
text-decoration: none;
color: #ffc;
border-radius: 4px;
outline: 0 none;
}
nav a:hover, nav a:focus
{
color: #fff;
background-color: #543;
text-shadow: 0 0 4px #fff;
box-shadow: inset 0 2px 2px rgba(0,0,0,0.2);
}
/* hovering */
article, article:after, nav, nav *
{
-webkit-transition: all 600ms ease;
-moz-transition: all 600ms ease;
-ms-transition: all 600ms ease;
-o-transition: all 600ms ease;
transition: all 600ms ease;
}
nav:hover
{
left: 0;
}
nav:hover ~ article
{
-webkit-transform: translateX(16em) perspective(600px) rotateY(10deg);
-moz-transform: translateX(16em) perspective(600px) rotateY(10deg);
-ms-transform: translateX(16em) perspective(600px) rotateY(10deg);
-o-transform: translateX(16em) perspective(600px) rotateY(10deg);
transform: translateX(16em) perspective(600px) rotateY(10deg);
}
nav:hover ~ article:after
{
left: 60%;
}
This can be used to create a 3d sliding menu as seen here