when you hover over the image blue arrow moves slowly. When you remove the cursor from the image white arrow comes back sharply. How to make a white arrow return slowly?
#keyframes left_to_right {
from {margin-left: -15px;}
to {margin-left: 0; }
}
div .footer-text{
position: absolute;
top: 10%;
left: 3%;
height: 20px;
width: 85%;
}
div .footer-text:after{
content: '';
background: url('https://www.nsartmuseum.ru/images/test/arrow-after-3.png') no-repeat;
width: 130px;
height: 15px;
display: inline-block;
margin-left: 10px;
position: relative;
}
div:hover .footer-text:before{
content: '';
background: url('https://www.nsartmuseum.ru/images/test/arrow-before-3.png') no-repeat;
width: 130px;
height: 15px;
margin-right: 5px;
display: inline-block;
animation: left_to_right 0.4s ease;
}
div:hover .footer-text:after{
content: '';
background: none;
}
div .footer-text span{
position: relative;
top:-5px;
font-size: 12px;
color: #313B78;
display: inline-block;
}
<div>
<a href="" class='footer-text'>
<span>13 September</span>
</a>
</div>
Obviously, there are ways to do this by CSS animation, but I've never used this in my development.
It's not required to use animation for that. transition is enough
just add transition: width .4s ease; to :after for unhovered element and play with width attribute
div .footer-text{
position: absolute;
top: 10%;
left: 3%;
height: 20px;
width: 85%;
}
div .footer-text span{
position: relative;
top:-5px;
font-size: 12px;
color: #313B78;
display: inline-block;
}
div .footer-text:after{
content: '';
background: url('https://www.nsartmuseum.ru/images/test/arrow-after-3.png') no-repeat right;
width: 130px;
height: 15px;
display: inline-block;
margin-left: 10px;
position: relative;
transition: width .4s ease;
}
div:hover .footer-text:after{
width: 0;
}
div .footer-text:before{
content: '';
background: url('https://www.nsartmuseum.ru/images/test/arrow-before-3.png') no-repeat right;
width: 0;
height: 15px;
margin-right: 5px;
display: inline-block;
transition: width .4s ease;
}
div:hover .footer-text:before{
width: 130px;
}
<div>
<a href="" class='footer-text'>
<span>13 September</span>
</a>
</div>
I do it:)
div {
width:50%;
position: relative;
height: 20px;
}
div .footer-text{
position: absolute;
top: 0;
left: 0;
line-height: 20px;
width: 100%;
height: 100%;
font-family: sans-serif;
overflow: hidden;
}
div .footer-text:before {
content: '';
background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20width%3D%228%22%20height%3D%2215%22%20viewBox%3D%220%200%208%2015%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M1%201.5l6%206-6%206%22%20stroke%3D%22%23C5C8D0%22%20stroke-width%3D%221.2%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E') no-repeat right center;
background-size: 8px;
width: 8px;
height: 15px;
position: absolute;
right: 0;
top: 50%;
transform: translate(0,-7px);
z-index: 2;
transition: .4s ease-in-out;
}
div .footer-text span {
position: absolute;
top: 0;
left: 0;
font-size: 12px;
color: #313B78;
display: block;
white-space: nowrap;
z-index: 1;
transition: .4s ease-in-out;
}
div .footer-text span:before {
content: '';
display: block;
width: 100vw;
height: 15px;
position: absolute;
top: 50%;
right: 100%;
margin: -7px 20px 0 0;
background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%221110%22%20height%3D%2214%22%20viewBox%3D%220%200%201110%2014%22%3E%3Cpath%20fill%3D%22%23313B78%22%20d%3D%22M1109.424%206.076l-6-6a.599.599%200%2010-.848.848l4.975%204.976H1a.6.6%200%20100%201.2h1106.551l-4.975%204.976a.599.599%200%2010.848.848l6-6a.6.6%200%20000-.848z%22%2F%3E%3C%2Fsvg%3E') no-repeat right top;
background-size: auto 14px;
}
div .footer-text span:after {
content: '';
display: block;
width: 100vw;
height: 1px;
position: absolute;
top: 50%;
background: #C5C8D0;
left: calc(100% + 20px);
}
div .footer-text:hover:before {
transform: translate(20px,-7px);
}
div .footer-text:hover span {
left: 100%;
transform: translateX(-100%);
}
<div>
<a href="" class='footer-text'>
<span>13 September</span>
</a>
</div>
#keyframes left_to_right {
from {
margin-left: -15px;
}
to {
margin-left: 0;
}
}
div .footer-text {
position: absolute;
top: 10%;
left: 3%;
height: 20px;
width: 85%;
}
div .footer-text:after {
content: '';
background: url('https://www.nsartmuseum.ru/images/test/arrow-after-3.png') no-repeat;
width: 130px;
height: 15px;
display: inline-block;
margin-left: 10px;
position: relative;
animation: left_to_right 0.4s ease;
}
div:hover .footer-text:before {
content: '';
background: url('https://www.nsartmuseum.ru/images/test/arrow-before-3.png') no-repeat;
width: 130px;
height: 15px;
margin-right: 5px;
display: inline-block;
animation: left_to_right 0.4s ease;
}
div:hover .footer-text:after {
display: none;
}
div .footer-text span {
position: relative;
top: -5px;
font-size: 12px;
color: #313B78;
display: inline-block;
}
<div>
<a href="" class='footer-text'>
<span>13 September</span>
</a>
</div>
Related
here is a simplified version of my webpage. I am experiencing an issue where my buttons ( tags) are overlapping my main h1 element. How can I fix this, so they do not overlap? I believe that the issue is being caused because I have set the position of the div #MOVE to fixed. However, I need this due to my animated navigation bar.
HTML:
<!DOCTYPE html>
<html>
<head>
<link href="main.css" rel="stylesheet" type="text/css">
<script src="jquery-1.10.2.min.js">
</script>
<script src="main.js">
</script>
<title>A'S COFFEE</title>
</head>
<body>
<div id="MOVE">
<h1 class="logoone">COFFEE.</h1>
<h1 class="logotwo">BETTER WITH A'S</h1>
</div>
<div class="centeralign">
<a class="button" href="place.html" id="btn1">Want to Place<br>
an Order?</a><br>
<a class="button" href="#" id="btn2">View Orders?</a>
</div>
<footer></footer>
</body>
</html>
CSS:
h1{
color: #e5b78e;
font-family: Arial;
font-size: 100pt;
padding: 0px;
margin: 0px;
display: block;
}
.logoone{
margin-left: 50px;
padding-top: 40px;
letter-spacing: 15px;
}
.logotwo{
margin-left: 50px;
margin-bottom: 70px;
letter-spacing: 15px;
}
body{
background: url("../img/image3.jpg") no-repeat center center fixed;
background-size: cover;
}
.button{
text-decoration: none;
padding: 30px;
background-color: white;
opacity: 0.5;
font-family: arial;
font-size: 25pt;
text-transform: uppercase;
font-weight: bolder;
color: #202530;
border-radius: 1px;
transition: opacity .2s ease-out;
margin-top: 10px;
letter-spacing: 4px;
}
.button a{
color: rgba(0,0,0,0.5);
}
#btn1{
margin-top:30px;
display: inline-block;
padding-left: 30px;
padding-right:30px;
}
#btn2{
margin-top:30px;
display: inline-block;
padding-left: 47px;
padding-right: 47px;
}
.button:hover{
opacity: 1;
transition: opacity .2s ease-in;
}
.centeralign{
text-align: center;
}
br{
padding: 40px;
}
/* NAV */
#MenuIcon{
height: 25px;
width: 50px;
position: fixed;
top:50;
right: 50;
}
#MenuIcon:hover{
cursor: pointer;
}
#MenuLine{
height: 4px;
width: 50px;
background-color: #e5b78e;
position: absolute;
top:50%;
left: 50%;
transform: translate(-50%,-50%);
transition: all .3s;
}
#MenuIcon:hover #MenuLine{
width: 40px;
}
#MenuLine::before{
content: '';
height: 4px;
width: 40px;
background-color: #e5b78e;
position: absolute;
margin-top: 10px;
transition: all .3s;
}
#MenuIcon:hover #MenuLine::before{
width: 50px;
}
#MenuLine::after{
content: '';
height: 4px;
width: 40px;
background-color: #e5b78e;
position: absolute;
margin-top: -10px;
transition: all .3s;
}
#MenuIcon:hover #MenuLine::after{
width: 50px;
}
#MainMenu{
height: 100vh;
width: 300px;
background-color: #181818;
-webkit-clip-path:polygon(0 0,100% 0,0% 100%,0% 100%);
position: fixed;
top:0;
left: -300px;
transition: all .5s ease-in-out;
}
ul{
list-style: none;
padding: 0px;
margin: 0px;
font-family: arial;
font-weight: bold;
color:white;
text-align: center;
position: absolute;
top: 55%;
left: 50%;
transform: translate(-50%,-50%);
}
ul li{
margin: 20px;
}
ul li:hover{
cursor: pointer;
}
.line{
height: 2px;
width: 150px;
background-color: white;
margin-top: 10px;
position: absolute;
left: 50%;
transform: translate(-50%);
transition: all .3s;
}
ul li:hover .line{
width: 180px;
}
#logo{
position: absolute;
top:100;
left: 50%;
transform: translate(-50%);
}
#close{
position: absolute;
bottom: 150;
left: 50%;
transform: translate(-50%);
}
#close:hover{
cursor: pointer;
}
.LOGO{
font-size: 4.5em;
}
#MOVE{
position:fixed;
top:0%;
left: 0px;
transition: all .5s ease-in-out;
width:85%;
height: 100%;
}
Try
#MOVE{
position:relative;
top:0%;
left: 0px;
transition: all .5s ease-in-out;
width:85%;
height: 100%;
}
That sets the position relative to other elements within the page
I am trying to make a switch button by using HTML elements. But I can't do animation for this. Here I have tried to use transition CSS3 property. The transition will work for some elements only and its doesn't work as expected for switch-group:before element. Is there any way to improve more animation to get an attractive one?. I have tried many links but this doesn't help with my code. I have attached code below,
input[type=checkbox] {
display: none;
}
.switch-wrapper {
position: relative;
width: 70px;
border: 1px solid;
cursor: pointer;
height: 22px;
overflow: hidden;
}
.switch-on,
.switch-off {
display: block;
width: 50%;
float: left;
height: 100%;
transition: 0.5s;
}
.switch-on {
background-color: red;
margin-left: -100%;
text-indent: -18px;
line-height: 21px;
text-align: center;
}
.switch-off {
text-indent: 18px;
line-height: 21px;
text-align: center;
background-color: aliceblue;
}
.switch-group:before {
display: block;
content: "";
position: absolute;
height: 18px;
width: 18px;
margin: 2px;
background-color: #1b191e;
top: 0px;
}
.switch-group {
display: block;
position: relative;
height: 23px;
width: 200%;
user-select: none;
}
input[type=checkbox]:checked+.switch-group .switch-on {
margin-left: 0;
}
input[type=checkbox]:checked+.switch-group:before {
right: 50%;
}
<div class="switch-wrapper">
<input type="checkbox" id="checked" />
<label class="switch-group" for="checked">
<span class="switch-on">ON</span>
<span class="switch-off">OFF</span>
</label>
</div>
The transition will not work in your :before pseudo element because you are changing the :before right value from auto(by default) to 0...transition does not works on auto values...
So try to use left:0 at start and then change it value on click(when input checked) using calc() and also use transtion:0.5s in :before to make it animate
input[type=checkbox] {
display: none;
}
.switch-wrapper {
position: relative;
width: 70px;
border: 1px solid;
cursor: pointer;
height: 22px;
overflow: hidden;
}
.switch-on,
.switch-off {
display: block;
width: 50%;
float: left;
height: 100%;
transition: 0.5s;
}
.switch-on {
background-color: red;
margin-left: -50%;
text-indent: -18px;
line-height: 21px;
text-align: center;
}
.switch-off {
text-indent: 18px;
line-height: 21px;
text-align: center;
background-color: aliceblue;
}
.switch-group:before {
display: block;
content: "";
position: absolute;
height: 18px;
width: 18px;
margin: 2px;
background-color: #1b191e;
top: 0px;
left: 0;
transition: 0.5s;
}
.switch-group {
display: block;
position: relative;
height: 23px;
width: 200%;
user-select: none;
}
input[type=checkbox]:checked+.switch-group .switch-on {
margin-left: 0;
}
input[type=checkbox]:checked+.switch-group:before {
left: calc(50% - 22px);
}
<div class="switch-wrapper">
<input type="checkbox" id="checked" />
<label class="switch-group" for="checked">
<span class="switch-on">ON</span>
<span class="switch-off">OFF</span>
</label>
</div>
Or if you want your code to work in more intuitive way, try to use opacity instead of margin.
I have changed some of your css a little bit
input[type=checkbox] {
display: none;
}
.switch-wrapper {
position: relative;
width: 70px;
border: 1px solid;
cursor: pointer;
height: 22px;
overflow: hidden;
}
.switch-on,
.switch-off {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
transition: 0.5s;
padding: 2px 6px;
}
.switch-on {
background-color: red;
line-height: 21px;
opacity: 0;
}
.switch-off {
line-height: 21px;
background-color: aliceblue;
opacity: 1;
text-align: right;
}
.switch-group:before {
display: block;
content: "";
position: absolute;
height: 18px;
width: 18px;
margin: 2px;
background-color: #1b191e;
top: 0px;
left: 0;
transition: 0.5s;
z-index: 99;
}
.switch-group {
display: block;
position: relative;
height: 23px;
user-select: none;
}
input[type=checkbox]:checked+.switch-group .switch-on {
opacity: 1;
}
input[type=checkbox]:checked+.switch-group .switch-off {
opacity: 0;
}
input[type=checkbox]:checked+.switch-group:before {
left: calc(100% - 22px);
}
<div class="switch-wrapper">
<input type="checkbox" id="checked" />
<label class="switch-group" for="checked">
<span class="switch-on">ON</span>
<span class="switch-off">OFF</span>
</label>
</div>
Try this toggler
.onoffswitch {
position: relative; width: 48px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
height: 24px; padding: 0; line-height: 24px;
border: 2px solid #F1F1F5; border-radius: 24px;
background-color: #F1F1F5;
transition: background-color 0.3s ease-in;
}
.onoffswitch-label:before {
content: "";
display: block; width: 24px; margin: 0px;
background: #FFFFFF;
position: absolute; top: 0; bottom: 0;
right: 22px;
border: 2px solid #F1F1F5; border-radius: 24px;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label {
background-color: #2DC76D;
}
.onoffswitch-checkbox:checked + .onoffswitch-label, .onoffswitch-checkbox:checked + .onoffswitch-label:before {
border-color: #2DC76D;
}
.onoffswitch-checkbox:checked + .onoffswitch-label:before {
right: 0px;
}
.onoffswitch-checkbox:checked + .onoffswitch-label span.switch-off {
opacity: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label span.switch-on{
opacity: 1;
}
span.switch-off {
opacity: 1;
float: right;
font-size: 12px;
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
}
span.switch-on {
position: absolute;
font-size: 12px;
top: 50%;
transform: translateY(-50%);
opacity: 0;
}
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch">
<label class="onoffswitch-label" for="myonoffswitch">
<span class="switch-on">ON</span>
<span class="switch-off">OFF</span></label>
</div>
You Can Try This.. Or visit This link For Details
.onoffswitch {
position: relative; width: 90px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
border: 2px solid #999999; border-radius: 20px;
}
.onoffswitch-inner {
display: block; width: 200%; margin-left: -100%;
transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
display: block; float: left; width: 50%; height: 30px; padding: 0; line-height: 30px;
font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
box-sizing: border-box;
}
.onoffswitch-inner:before {
content: "ON";
padding-left: 10px;
background-color: #34A7C1; color: #FFFFFF;
}
.onoffswitch-inner:after {
content: "OFF";
padding-right: 10px;
background-color: #EEEEEE; color: #999999;
text-align: right;
}
.onoffswitch-switch {
display: block; width: 18px; margin: 6px;
background: #FFFFFF;
position: absolute; top: 0; bottom: 0;
right: 56px;
border: 2px solid #999999; border-radius: 20px;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
I have the following grid of divs
<div id="container">
<div class="imgContainer">
<div class="ar-image">
<div style="background: url('http://maximumwallhd.com/wp-content/uploads/2015/06/fonds-ecran-plage-palmier-12-660x330.jpg')" class="article-image"></div>
<p class="descfirst">Progressive</p>
<div class="first"><span class = "green" style="width: 85%"></span></div>
<p class="descsecond">Happy</p>
<div class="second"><span class = "green" style="width: 55%"></span></div>
<p class="descthird">Creative</p>
<div class="third"><span class = "green" style="width: 43%"></span></div>
<p class="descfourth">Slow</p>
<div class="fourth"><span class = "red" style="width: 75%"></span></div>
<p class="descfifth">Boring</p>
<div class="fifth"><span class = "red" style="width: 65%"></span></div>
<p class="descsixth">Text</p>
<div class="sixth"><span class = "red" style="width: 60%"></span></div>
<h1 class="topleft">1 | Scooter</h1>
<h3 class="topright">Rock</h3>
<h3 class="bottomleft">T 21%, C 6%</h3>
<h3 class="bottomright">XXX</h3>
</div>
<div class="ar-image">
<div style="background: url('http://maximumwallhd.com/wp-content/uploads/2015/06/fonds-ecran-plage-palmier-12-660x330.jpg')" class="article-image"></div>
<p class="descfirst">Progressive</p>
<div class="first"><span class = "green" style="width: 85%"></span></div>
<p class="descsecond">Happy</p>
<div class="second"><span class = "green" style="width: 55%"></span></div>
<p class="descthird">Creative</p>
<div class="third"><span class = "green" style="width: 43%"></span></div>
<p class="descfourth">Slow</p>
<div class="fourth"><span class = "red" style="width: 75%"></span></div>
<p class="descfifth">Boring</p>
<div class="fifth"><span class = "red" style="width: 65%"></span></div>
<p class="descsixth">Text</p>
<div class="sixth"><span class = "red" style="width: 60%"></span></div>
<h1 class="topleft">1 | Scooter</h1>
<h3 class="topright">Rock</h3>
<h3 class="bottomleft">T 21%, C 6%</h3>
<h3 class="bottomright">XXX</h3>
</div>
<div class="ar-image">
<div style="background: url('http://maximumwallhd.com/wp-content/uploads/2015/06/fonds-ecran-plage-palmier-12-660x330.jpg')" class="article-image"></div>
<p class="descfirst">Progressive</p>
<div class="first"><span class = "green" style="width: 85%"></span></div>
<p class="descsecond">Happy</p>
<div class="second"><span class = "green" style="width: 55%"></span></div>
<p class="descthird">Creative</p>
<div class="third"><span class = "green" style="width: 43%"></span></div>
<p class="descfourth">Slow</p>
<div class="fourth"><span class = "red" style="width: 75%"></span></div>
<p class="descfifth">Boring</p>
<div class="fifth"><span class = "red" style="width: 65%"></span></div>
<p class="descsixth">Text</p>
<div class="sixth"><span class = "red" style="width: 60%"></span></div>
<h1 class="topleft">3 | ABBA</h1>
<h3 class="topright">Rock</h3>
<h3 class="bottomleft">T 21%, C 6%</h3>
<h3 class="bottomright">XXX</h3>
</div>
</div>
.article-image{
height: 320px;
width: 480px;
-webkit-filter: grayscale(0) blur(0);
filter: grayscale(0) blur(0);
transition: .4s ease-in-out;
}
.ar-image:hover .article-image{
-webkit-filter: grayscale(100%) blur(2px);
filter: grayscale(100%) blur(2px);
transition: .1s ease-in-out;
}
.ar-image{
position: relative;
display:inline-block;
padding: 1%;
width: 25.66%;
}
.ar-image > p{
display: none;
}
.ar-image:hover > p{
position: absolute;
top: 0;
display: block;
color: #ffffff;
font-size: 16px;
font-weight: bold;
z-index: 0;
width: 100%;
height: 100%;
text-align: center;
transition: .4s ease-in-out;
line-height:150px;
margin:0;
}
.ar-image > p.descfirst, p.descsecond, p.descthird, p.descfourth, p.descfifth, p.descsixth{
display: none;
}
.ar-image:hover > p.descfirst{
position: absolute;
top: 40px;
left: 40px;
display: block;
color: #ffffff;
font-size: 16px;
font-weight: bold;
z-index: 0;
width: 100%;
height: 100%;
text-align: left;
transition: .4s ease-in-out;
line-height:25px;
margin:0;
}
.ar-image:hover > p.descsecond{
position: absolute;
top: 80px;
left: 40px;
display: block;
color: #ffffff;
font-size: 16px;
font-weight: bold;
z-index: 0;
width: 100%;
height: 100%;
text-align: left;
transition: .4s ease-in-out;
line-height:25px;
margin:0;
}
.ar-image:hover > p.descthird{
position: absolute;
top: 120px;
left: 40px;
display: block;
color: #ffffff;
font-size: 16px;
font-weight: bold;
z-index: 0;
width: 100%;
height: 100%;
text-align: left;
transition: .4s ease-in-out;
line-height:25px;
margin:0;
}
.ar-image:hover > p.descfourth{
position: absolute;
top: 200px;
left: 40px;
display: block;
color: #ffffff;
font-size: 16px;
font-weight: bold;
z-index: 0;
width: 100%;
height: 100%;
text-align: left;
transition: .4s ease-in-out;
line-height:25px;
margin:0;
}
.ar-image:hover > p.descfifth{
position: absolute;
top: 240px;
left: 40px;
display: block;
color: #ffffff;
font-size: 16px;
font-weight: bold;
z-index: 0;
width: 100%;
height: 100%;
text-align: left;
transition: .4s ease-in-out;
line-height:25px;
margin:0;
}
.ar-image:hover > p.descsixth{
position: absolute;
top: 280px;
left: 40px;
display: block;
color: #ffffff;
font-size: 16px;
font-weight: bold;
z-index: 0;
width: 100%;
height: 100%;
text-align: left;
transition: .4s ease-in-out;
line-height:25px;
margin:0;
}
.ar-image > div.first, div.second, div.third, div.fourth, div.fifth, div.sixth{
display: none;
}
.ar-image:hover > div.first{
position: absolute;
top: 40px;
left: 200px;
display: block;
height: 25px; /* Can be anything */
background-color: rgba(85,85,85,0.4);
bottom: 20px;
right: -40px;
width: 45%;
}
.ar-image:hover > div.second{
position: absolute;
top: 80px;
left: 200px;
display: block;
height: 25px; /* Can be anything */
position: absolute;
background-color: rgba(85,85,85,0.4);
bottom: 20px;
right: -40px;
width: 45%;
}
.ar-image:hover > div.third{
position: absolute;
top: 120px;
left: 200px;
display: block;
height: 25px; /* Can be anything */
position: absolute;
background-color: rgba(85,85,85,0.4);
bottom: 20px;
right: -40px;
width: 45%;
}
.ar-image:hover > div.fourth{
position: absolute;
top: 200px;
left: 200px;
display: block;
height: 25px; /* Can be anything */
position: absolute;
background-color: rgba(85,85,85,0.4);
bottom: 20px;
right: -40px;
width: 45%;
}
.ar-image:hover > div.fifth{
position: absolute;
top: 240px;
left: 200px;
display: block;
height: 25px; /* Can be anything */
position: absolute;
background-color: rgba(85,85,85,0.4);
bottom: 20px;
right: -40px;
width: 45%;
}
.ar-image:hover > div.sixth{
position: absolute;
top: 280px;
left: 200px;
display: block;
height: 25px; /* Can be anything */
position: absolute;
background-color: rgba(85,85,85,0.4);
bottom: 20px;
right: -40px;
width: 45%;
}
.ar-image > div > span.green{
display: block;
height: 100%;
background-color: rgb(43,194,83);
position: relative;
overflow: hidden;
}
.ar-image > div > span.red{
display: block;
height: 100%;
background-color: #ff4742;
position: relative;
overflow: hidden;
}
.ar-image > h1.topleft{
display: visible;
position: absolute;
text-align: left;
color: #ffffff;
top: 15px;
right: -40px;
width: 100%;
}
.ar-image:hover > h1.topleft{
display: none;
}
.ar-image > h3.bottomleft{
display: visible;
position: absolute;
text-align: left;
color: #ffffff;
bottom: 20px;
right: -40px;
width: 100%;
}
.ar-image:hover > h3.bottomleft{
display: none;
}
.ar-image > h3.bottomright{
visibility:visible;
position: absolute;
text-align: left;
color: #ffffff;
bottom: 20px;
left: 440px;
width: 100%;
}
.ar-image:hover > h3.bottomright{
display: none;
}
.ar-image > h3.topright{
visibility:visible;
position: absolute;
text-align: left;
color: #ffffff;
top: 15px;
left: 440px;
width: 100%;
}
.ar-image:hover > h3.topright{
display: none;
}
On hover the image gets blurred and a set of css progress bars is overlaid. I also want each of the divs to have a link but so far was unsuccessful in implementing this without breaking the hover effect.
Any suggestions how a link can be implemented for the whole div (inkl. the and )?
UPDATE
When I wrap the whole div in an atag it breajs the hover effekt
Just tried and wrapping ar-image with a tags seems to work. I might not be understanding your question though.
I have a button that, when pressed, is supposed to expand the element behind it (.nav which contains .work and .contact) out in both directions. However, I can't seem to keep the button in the center.
$(function() {
var nav = $('.nav');
var button = $('.nav button');
button.on('click', function(){
nav.toggleClass('active');
if(nav.hasClass('active'))
button.text('');
else
button.text('');
});
});
html {
background: #f1f1f1;
}
.nav {
display: block;
margin: auto;
margin-top: 80px;
margin-bottom: 200px;
background: #ccc;
color: black;
text-align: center;
width: 350px;
height: 330px;
transition: width 0.5s;
}
.nav.active {
width: 1000px;
transition: width 0.5s;
}
.navigation button {
position: absolute;
width: 350px;
Height: 350px;
margin: 0 auto;
display: block;
background-color: #2e0513!important;
background: url(TransplantAltFontbackgroundvector.png) 12px 15px;
background-repeat: no-repeat;
background-size: 325px 325px;
border: none;
transition: 0.5s ease-in-out;
}
.navigation.active button {
transform: scale(1.1);
transition: 0.5s ease-in-out;
}
.navigation:hover button {
box-shadow: 0px 0px 20px black;
transform: scale(1.01);
transition: 0.1s ease-in-out;
}
.navigation.active:hover button {
box-shadow: none!important;
transform: scale(1.1)!important;
transition: 0.5s ease-in-out;
}
.navigation button img {
position: relative;
right: 30px;
bottom: 40px;
}
.work,
.contact {
position: relative;
visibility: hidden;
}
.work a {
font-family: arapey;
font-size: 30px;
font-style: italic;
text-decoration: none;
}
.contact a {
font-family: arapey;
font-size: 30px;
font-style: italic;
text-decoration: none;
}
.nav.active > .work {
visibility: visible!important;
display: table;
margin: auto;
position: relative;
float: left;
left: 125px;
top: 150px;
}
.nav.active > .contact {
visibility: visible!important;
display: table;
margin: auto;
position: relative;
float: right;
right: 125px;
top: 150px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="navigation">
<div class="nav">
<button>
</button>
<div class="work">
work
</div>
<div class="contact">
contact
</div>
</div>
</div>
Give the nav a style of position: relative. Then, toggle a class (or just add the styling, should work as well) to the button on click that does the following:
button.my-pressed-class {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
This should keep it in the middle.
Edit: Keep in mind you already have a transform set on the button on hover. Just, add the translateX to hover when the button has the aforementioned class, to avoid it from moving around on hover.
add postion relative to .navigation and position absolute to .nav with left value
$(function() {
var nav = $('.nav');
var button = $('.nav button');
button.on('click', function(){
nav.toggleClass('active');
if(nav.hasClass('active'))
button.text('');
else
button.text('');
});
});
html {
background: #f1f1f1;
}
.navigation {
position: relative;
}
.nav {
display: block;
margin: auto;
margin-top: 80px;
margin-bottom: 200px;
background: #ccc;
color: black;
text-align: center;
width: 350px;
height: 330px;
transition: width 0.5s;
position: absolute;
left: 100px;
}
.nav.active {
width: 1000px;
transition: width 0.5s;
}
.navigation button {
position: absolute;
width: 350px;
Height: 350px;
margin: 0 auto;
display: block;
background-color: #2e0513!important;
background: url(TransplantAltFontbackgroundvector.png) 12px 15px;
background-repeat: no-repeat;
background-size: 325px 325px;
border: none;
transition: 0.5s ease-in-out;
}
.navigation.active button {
transform: scale(1.1);
transition: 0.5s ease-in-out;
}
.navigation:hover button {
box-shadow: 0px 0px 20px black;
transform: scale(1.01);
transition: 0.1s ease-in-out;
}
.navigation.active:hover button {
box-shadow: none!important;
transform: scale(1.1)!important;
transition: 0.5s ease-in-out;
}
.navigation button img {
position: relative;
right: 30px;
bottom: 40px;
}
.work,
.contact {
position: relative;
visibility: hidden;
}
.work a {
font-family: arapey;
font-size: 30px;
font-style: italic;
text-decoration: none;
}
.contact a {
font-family: arapey;
font-size: 30px;
font-style: italic;
text-decoration: none;
}
.nav.active > .work {
visibility: visible!important;
display: table;
margin: auto;
position: relative;
float: left;
left: 125px;
top: 150px;
}
.nav.active > .contact {
visibility: visible!important;
display: table;
margin: auto;
position: relative;
float: right;
right: 125px;
top: 150px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="navigation">
<div class="nav">
<button>
</button>
<div class="work">
work
</div>
<div class="contact">
contact
</div>
</div>
</div>
I want to target the :after element when I hover over the #btn-home button.
#btn-home a {
display: inline-block;
color: #707070;
font-size: 1.15em;
font-weight: 600;
margin: 0 20px;
}
#btn-home {
position: relative;
display: inline-block;
margin: 0;
}
#btn-home a:after {
display: block;
position: absolute;
content: '';
margin: 0 auto;
height: 3px;
width: 25px;
background-color: red;
bottom: -7px;
left: 0;
right: 0;
}
<div id="btn-home">
HOME
</div>
I want to target the width of the :after element when hovered over #btn-home.
That is pretty easy to do. Just use the selector as #btn-home:hover a:after.
#btn-home a {
display: inline-block;
color: #707070;
font-size: 1.15em;
font-weight: 600;
margin: 0 20px;
}
#btn-home {
position: relative;
display: inline-block;
margin: 0;
}
#btn-home a:after {
display: block;
position: absolute;
content: '';
margin: 0 auto;
height: 3px;
width: 25px;
background-color: red;
bottom: -7px;
left: 0;
right: 0;
transition: all 1s ease; /* just for demo */
}
#btn-home:hover a:after{
width: 100px;
<div id="btn-home">
HOME
</div>
You need to add this in your code :
#btn-home a:after {
transition:all .4s linear;
}
#btn-home:hover a:after {
width: 50px;
}
#btn-home a {
display: inline-block;
color: #707070;
font-size: 1.15em;
font-weight: 600;
margin: 0 20px;
}
#btn-home {
position: relative;
display: inline-block;
margin: 0;
}
#btn-home a:after {
display: block;
position: absolute;
content: '';
margin: 0 auto;
height: 3px; width: 25px;
background-color: red;
bottom: -7px; left: 0; right: 0;
transition:all .4s linear;
}
#btn-home:hover a:after {
width: 50px;
}
<div id="btn-home">
HOME
</div>