Is it possible to have this Hover effect without SVG - html

I'm trying to create something like this without SVG ? is it possible ?
Demo
Fiddle
.hover {
background: salmon;
text-align: center;
width: 70px;
height: 50px;
transition: all 0.5s ease-in;
-moz-transition: all 0.5s ease-in;
-o-transition: all 0.5s ease-in;
-webkit-transition: all 0.5s ease-in;
}
.hover:hover {
border: 2px solid grey;
}
<div class="hover">hover me</div>

Not exactly like it but almost there
.container {
display:inline-block;
overflow:hidden;
position:relative;
}
.container div {
position:relative;
width:200px;
height:200px;
background:grey;
transition:.5s all;
}
.container:before {
content:"";
position:absolute;
top:198px;
left:0;
width:200px;
height:2px;
z-index:2;
background:orange;
transition:.5s all;
transition-delay:.5s;
}
.container:after {
content:"";
position:absolute;
top:0;
right:00px;
width:2px;
height:200px;
background:orange;
transition:.5s all;
}
.container div:after {
top:0px;
content:"";
position:absolute;
width:200px;
height:2px;
background:orange;
transition:.5s all;
}
.container div:before {
top:0px;
left:0px;
content:"";
position:absolute;
width:2px;
height:200px;
background:orange;
transition:.5s all;
transition-delay:.5s;
}
.container:hover:after{
height:0;
}
.container:hover:before{
width:0;
}
.container div:hover:after {
width:0;
}
.container div:hover:before {
height:0;
}
<div class="container">
<div></div>
</div>

are you looking for something like this?
#keyframes width{
0%{width:100%; height:0%;}
50%{width:10%; height:10%;}
100%{width:0%; height:100%;}
}
#keyframes height{
0%{width:0%; height:100%;}
50%{width:10%; height:10%;}
100%{width:100%; height:0%;}
}
.effect{float:left; margin:15px; position:relative;}
.effect .content{ top:0px; left:0px; right:0px; bottom:0px; background-color:transparent; color:#000;}
.effect div{ width:100%; height:100%; position:absolute;
animation-fill-mode:forwards;}
.effect .top{top:-1px; left:-1px; border-top:1px solid #aaa; border-left:1px solid #aaa;}
.effect .bottom{bottom:-1px; right:-1px; border-bottom:1px solid #aaa; border-right:1px solid #aaa;}
.effect .left{left:-1px; bottom:-1px; border-bottom:1px solid #aaa; border-left:1px solid #aaa;}
.effect .right{top:-1px; right:-1px; border-right:1px solid #aaa; border-top:1px solid #aaa;}
.effect:hover .top{animation:width 0.7s ease-in 0s 1;}
.effect:hover .bottom{animation:width 0.7s ease-in 0s 1;}
.effect:hover .left{animation:height 0.7s ease-in 0s 1;}
.effect:hover .right{animation:height 0.7s ease-in 0s 1;}
.effect:not(:hover) .top{animation:height 0.7s ease-in 0s 1;}
.effect:not(:hover) .bottom{animation:height 0.7s ease-in 0s 1;}
.effect:not(:hover) .left{animation:width 0.7s ease-in 0s 1;}
.effect:not(:hover) .right{animation:width 0.7s ease-in 0s 1;}
<div class="effect">
Try hover
<div class="top"></div>
<div class="bottom"></div>
<div class="left"></div>
<div class="right"></div>
<div class="content"></div>
</div>
<div class="effect">
Try hover
<div class="top"></div>
<div class="bottom"></div>
<div class="left"></div>
<div class="right"></div>
<div class="content"></div>
</div>
<div class="effect">
Try hover
<div class="top"></div>
<div class="bottom"></div>
<div class="left"></div>
<div class="right"></div>
<div class="content"></div>
</div>

Yes, though I can't write the CSS for you at the moment. It's simply a matter of using :hover to change the height and width or padding or border of that element. Use transitions for a smooth effect. You don't need animation or SVG at all.

CSS
.test {
display: inline-block;
border-radius: 0px;
border: 1px solid pink;
transition: all 1s;
}
.test:hover {
border-radius: 0 20px;
border: 20px solid rgba(0, 0, 0, 0.5);
background-color: purple;
color: yellow;
padding: 50px;
font-size: 30px;
}
<div class="test">hover me for fun and exitment</div>
.box {
fill: #4a2;
stroke: #412;
stroke-width: 1;
transition: all 1s;
}
.box:hover {
stroke-width: 5;
stroke: #22a;
fill: red;
}
<svg width="200px" height="200px" viewBox="0 0 100 100">
<rect class="box" x="20" y="50" width="50" height="30" />
</svg>

Related

How to show Link/DIV on hover with moving up the upper div?

I'm trying to build a Team section on a Website. I have a Div with an Image and Name of the Person. When I hover over the name, I would like to have a link to appear on its place and move the Name upwards.
Something like this (TEAM Section):
https://www.templatemonster.com/de/demo/55809.html
I tried using a solution I found here and modifying it, but it doesnt really work like I want it to:
#stuff {
position: absolute;
top: 100px;
opacity: 0.0;
-webkit-transition: all 500ms ease-in-out;
-moz-transition: all 500ms ease-in-out;
-ms-transition: all 500ms ease-in-out;
-o-transition: all 500ms ease-in-out;
transition: all 500ms ease-in-out;
}
#hover {
width:80px;
height:20px;
background-color:green;
margin-top: 50px;
margin-bottom:15px;
}
#hover:hover {
margin-top:25px;
margin-bottom: 25px;
opacity: 1.0;
}
#stuff:hover {
opacity: 1.0;
}
<link rel="stylesheet" type="text/css" href="main.css">
<section>
<div id="hover">Hover</div>
<div id="stuff">stuff</div>
Is there a simple solution with CSS and/or Bootstrap?
I made an example using just css.
section {
margin:5px auto;
}
.hover-div {
color:#FFF;
width:200px;
}
.hover-div .stuff {
background-color:#F00;
height:100px;
margin-top:0;
position:relative;
width:100%;
z-index:2;
-webkit-transition:margin-top 0.3s;
transition:margin-top 0.3s;
}
.hover-div .stuff-hidden {
background-color:#00F;
height:0;
width:100%;
-webkit-transition:height 0.3s;
transition:height 0.3s;
}
.hover-div:hover .stuff {
margin-top:-40px;
}
.hover-div:hover .stuff-hidden {
height:40px;
}
.image {
background-color:#0F0;
height:100px;
text-align:center;
width:100%;
}
<section>
<div class="image">image</div>
<div class="hover-div">
<div class="stuff">Stuff</div>
<div class="stuff-hidden">Hidden stuff</div>
</div>
</section>

How to make smooth animation in css?

I have used animation of translate(). The link to the code is here Bouncy animation
But it starts off abruptly at the bottom. How to give it a smooth start. Also notice the animation distorts in between. How to remove such error?
The code is below:
body{background: #92348A;
font-family:'Helvetica Neue',Arial, Helvetica, sans-serif;}
.wrapper{ margin-left:370px;
margin-top:195px;
position:absolute;
}
p{ font-family: "Comic Sans MS", cursive;
font-weight:900;
}
.one{width:50px;
height:50px;
float:left;
margin:0.5em;
position:relative;
border-radius:100%;
background: #F00;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.2s infinite ;
}
.two{width:50px;
height:50px;
float:left;
margin:1em;
position:relative;
border-radius:100%;
background: #9D1A76;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.38s infinite;}
.three{width:50px;
height:50px;
float:left;
margin:1em;
position:relative;
border-radius:100%;
background: #FF0080;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.3s infinite;}
.four{width:50px;
height:50px;
float:left;
margin:1em;
position:relative;
border-radius:100%;
background: #FF0;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.35s infinite;}
.five{width:50px;
height:50px;
float:left;
margin:1em;
position:relative;
border-radius:100%;
background: #0ECAF1;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.23s infinite;}
.six{width:50px;
height:50px;
float:left;
margin:1em;
position:relative;
border-radius:100%;
background: #0BF451;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.1s infinite;}
.seven{width:50px;
height:50px;
float:left;
margin:1em;
position:relative;
border-radius:100%;
background: #645CF1;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.14s infinite;}
#-webkit-keyframes bounce{
2%{ transform: translateY(120px);}
50%{ transform:translateY(-90px);}
100%{ transform:translateY(120px);}
}
<body>
<div class="wrapper">
<div class="one">
<p>W</p>
</div>
<div class="two">
<p>E</p>
</div>
<div class="three">
<p>L</p>
</div>
<div class="four">
<p>C</p>
</div>
<div class="five">
<p>O</p>
</div>
<div class="six">
<p>M</p>
</div>
<div class="seven">
<p>E</p>
</div>
</div>
</body>
#harcos answer is correct, but does not have a smooth start.
Add the transform:translateY(-90px);
to all the different animation classes for them to be rendered where the animation starts.
body {
background: #92348A;
font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
}
.wrapper {
margin-left: 370px;
margin-top: 195px;
position: absolute;
}
p {
font-family: "Comic Sans MS", cursive;
font-weight: 900;
}
.one {
width: 50px;
height: 50px;
float: left;
margin: 0.5em;
position: relative;
border-radius: 100%;
background: #F00;
text-align: center;
transform:translateY(-90px);
-webkit-animation: bounce 2s cubic-bezier(0.1, 0.1, .3, 1.9) 0.2s infinite;
}
.two {
width: 50px;
height: 50px;
float: left;
margin: 1em;
position: relative;
border-radius: 100%;
background: #9D1A76;
text-align: center;
transform:translateY(-90px);
-webkit-animation: bounce 2s cubic-bezier(0.1, 0.1, .3, 1.9) 0.38s infinite;
}
.three {
width: 50px;
height: 50px;
float: left;
margin: 1em;
position: relative;
border-radius: 100%;
background: #FF0080;
text-align: center;
transform:translateY(-90px);
-webkit-animation: bounce 2s cubic-bezier(0.1, 0.1, .3, 1.9) 0.3s infinite;
}
.four {
width: 50px;
height: 50px;
float: left;
margin: 1em;
position: relative;
border-radius: 100%;
background: #FF0;
text-align: center;
transform:translateY(-90px);
-webkit-animation: bounce 2s cubic-bezier(0.1, 0.1, .3, 1.9) 0.35s infinite;
}
.five {
width: 50px;
height: 50px;
float: left;
margin: 1em;
position: relative;
border-radius: 100%;
background: #0ECAF1;
text-align: center;
transform:translateY(-90px);
-webkit-animation: bounce 2s cubic-bezier(0.1, 0.1, .3, 1.9) 0.23s infinite;
}
.six {
width: 50px;
height: 50px;
float: left;
margin: 1em;
position: relative;
border-radius: 100%;
background: #0BF451;
text-align: center;
transform:translateY(-90px);
-webkit-animation: bounce 2s cubic-bezier(0.1, 0.1, .3, 1.9) 0.1s infinite;
}
.seven {
width: 50px;
height: 50px;
float: left;
margin: 1em;
position: relative;
border-radius: 100%;
background: #645CF1;
text-align: center;
transform:translateY(-90px);
-webkit-animation: bounce 2s cubic-bezier(0.1, 0.1, .3, 1.9) 0.14s infinite;
}
#-webkit-keyframes bounce{
0%{ transform:translateY(-90px);}
50%{ transform:translateY(120px);}
100%{ transform:translateY(-90px);}
}
<body>
<div class="wrapper">
<div class="one">
<p>W</p>
</div>
<div class="two">
<p>E</p>
</div>
<div class="three">
<p>L</p>
</div>
<div class="four">
<p>C</p>
</div>
<div class="five">
<p>O</p>
</div>
<div class="six">
<p>M</p>
</div>
<div class="seven">
<p>E</p>
</div>
</div>
</body>
#-webkit-keyframes bounce{
0%{ transform:translateY(-90px);}
50%{ transform:translateY(120px);}
100%{ transform:translateY(-90px);}
}
body{background: #92348A;
font-family:'Helvetica Neue',Arial, Helvetica, sans-serif;}
.wrapper{ margin-left:370px;
margin-top:195px;
position:absolute;
}
p{ font-family: "Comic Sans MS", cursive;
font-weight:900;
}
.one{width:50px;
height:50px;
float:left;
margin:0.5em;
position:relative;
border-radius:100%;
background: #F00;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.2s infinite ;
}
.two{width:50px;
height:50px;
float:left;
margin:1em;
position:relative;
border-radius:100%;
background: #9D1A76;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.38s infinite;}
.three{width:50px;
height:50px;
float:left;
margin:1em;
position:relative;
border-radius:100%;
background: #FF0080;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.3s infinite;}
.four{width:50px;
height:50px;
float:left;
margin:1em;
position:relative;
border-radius:100%;
background: #FF0;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.35s infinite;}
.five{width:50px;
height:50px;
float:left;
margin:1em;
position:relative;
border-radius:100%;
background: #0ECAF1;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.23s infinite;}
.six{width:50px;
height:50px;
float:left;
margin:1em;
position:relative;
border-radius:100%;
background: #0BF451;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.1s infinite;}
.seven{width:50px;
height:50px;
float:left;
margin:1em;
position:relative;
border-radius:100%;
background: #645CF1;
text-align:center;
-webkit-animation:bounce 2s cubic-bezier(0.1,0.1,.3,1.9) 0.14s infinite;}
#-webkit-keyframes bounce{
2%{ transform: translateY(120px);}
50%{ transform:translateY(-90px);}
100%{ transform:translateY(120px);}
}
<body>
<div class="wrapper">
<div class="one">
<p>W</p>
</div>
<div class="two">
<p>E</p>
</div>
<div class="three">
<p>L</p>
</div>
<div class="four">
<p>C</p>
</div>
<div class="five">
<p>O</p>
</div>
<div class="six">
<p>M</p>
</div>
<div class="seven">
<p>E</p>
</div>
</div>
</body>

Keep elements fixed, next to a transforming element

How can i make an element that i transform its width and height not affect its surrounding elements ?
p {
position: relative;
}
.p1 {
width:200px;
height:200px;
border:1px solid blue;
outline: 1px solid green;
display:inline;
text-align:center;
background-color: red;
color: #FFF;
position:relative;
display:inline-block;
float:left;
-webkit-transition: width 2s, height 2s, background-color 2s, -webkit-transform 2s, color 2s;
}
.p1:hover {
width:500px;
height: 500px;
-webkit-transform: rotate(180deg);
color:black;
}
<p class="p1">hello1</p>
<p style="" class="p1">hello2</p>
<p style="" class="p1">hello3</p>
Demo at http://jsfiddle.net/toadalskii/mLx0x56n/
Do not scale it by changing the width/height since those affect the document flow.
Use the scale transform (from 200 to 500 it is a scale of 2.5) so use transform: scale(2.5) rotate(180deg);
body {
width:100%;
}
p {
position: relative;
}
.p1 {
width:200px;
height:200px;
border:1px solid blue;
outline: 1px solid green;
display:inline;
text-align:center;
background-color: red;
color: #FFF;
position:relative;
display:inline-block;
float:left;
-webkit-transition: background-color 2s, -webkit-transform 2s, color 2s;
transition: background-color 2s, transform 2s, color 2s;
}
.p1:hover {
-webkit-transform: scale(2.5) rotate(180deg);
transform: scale(2.5) rotate(180deg);
color:black;
z-index:100;
}
<p class="p1">hello1</p>
<p class="p1">hello2</p>
<p class="p1">hello3</p>
Demo at http://jsfiddle.net/mLx0x56n/1/

Display list in horizontal line - li in html with css

How to modify this code to display list in horizontal line menu
Currently this code displays in vertical
I want it in horizonyal line form
how make it display list in horizontal line form?
<html><head><style>
.metromenu {
display:block;;
position:relative;
width:40%;
margin:0 auto;
z-index:1;
}
.metromenu, .sub-metromenu {
list-style:none;
}
.metromenu li {
display:inline-block;
float:left;
margin-right:2px;
margin-top:2px;
}
.metromenu a{
display:block;
position:relative;
width:120px;
height:32px;
text-decoration:none;
font-family:'arial';
text-align:center;
letter-spacing:2px;
line-height:26px;
color:#fff;
padding:6px 20px 0 20px;
background-color: hsl(200,70%,50%);
-webkit-transition:all 0.2s ease-out;
-moz-transition:all 0.2s ease-out;
-o-transition:all 0.2s ease-out;
}
.metromenu a:hover {
background-color: hsl(200,80%,65%);
}
.metromenu span {
display:inline-block;;
position:absolute;
top:18px;
right:10px;
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 6px solid #fff;
}
.metromenu li:hover > a{ /* activates link when mouse over sub-metromenu */
background-color: hsl(200,80%,65%);
}
/*sub-metromenu trigger*/
.metromenu li a:hover ~ ul{
opacity:1;
visibility:visible;
}
.sub-metromenu {
opacity:0;
visibility:hidden;
position:absolute;
z-index:10;
-webkit-transition:all 0.2s ease-out;
-moz-transition:all 0.2s ease-out;
-o-transition:all 0.2s ease-out;
}
.sub-metromenu:hover {
opacity:1;
visibility:visible;
}
.sub-metromenu li a{
background-color: hsl(250,70%,60%);
}
.sub-metromenu li:first-child a{
height:72px;
}
.sub-metromenu li a:hover{
background-color: hsl(250,80%,70%);
}
.metromenu .orange {
background-color: hsl(20,70%,60%);
}
.metromenu .orange:hover {
background-color: hsl(20,80%,70%);
}
.metromenu .green {
background-color: hsl(110,60%,60%);
}
.metromenu .green:hover {
background-color: hsl(110,70%,70%);
}
</style>
</head>
<body>
<div>
<ul class="metromenu">
<li>Web Tools</li>
<li>Smartphones<span></span>
<ul class="sub-metromenu">
<li>Latest Smartphones</li>
<li>Windows</li>
<li>Android</li>
</ul>
</li>
<li>Others</li>
</ul>
</div> </body> </html>
I took code from here http://codepen.io/maxim/pen/DrvLx
Try this
.metromenu {
display: block;
margin: 0 auto;
position: relative;
width: 100%;
z-index: 1;
}
I changed the width from 40% to 100%. Here is the fiddle. Let me know if this was helpful or if you have any queries.
Edit I [sub menu fix]: Also set the width for sub-menu or they will go vertical.
.sub-metromenu {
opacity:0;
visibility:hidden;
position:absolute;
z-index:10;
-webkit-transition:all 0.2s ease-out;
-moz-transition:all 0.2s ease-out;
-o-transition:all 0.2s ease-out;
width: 10%;
}
Updated fiddle

Parent DIV Height to expand based on inner content [duplicate]

This question already has answers here:
Expanding a parent <div> to the height of its children
(20 answers)
Closed 8 years ago.
I'm trying to set the height of .background based on the number of .slice elements on the page. I know the inner elements being floated left doesn't help but I'm not sure how to solve this.
JSFiddle
http://jsfiddle.net/8ryAD/
HTML
<div class="master">
<a id="btn-nav">
<span></span>
<span>Menu</span>
<span></span>
</a>
<nav id="main-nav">
<div class="background">
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
</div>
</nav>
</div><!-- end master -->
CSS
#import url(http://fonts.googleapis.com/css?family=Droid+Sans);
body {
background: #2980b9;
font-family: 'Droid Sans', sans-serif;
}
#btn-nav {
position:absolute;
left:10px;
top:10px;
width:30px;
height:30px;
display:block;
z-index:1;
}
#btn-nav:hover {
cursor:pointer;
}
#btn-nav span:nth-child(2) {
top:10px;
}
#btn-nav span:nth-child(3) {
top:20px;
}
#btn-nav span {
height: 4px;
width: 30px;
background: white;
content: "";
text-indent: -999em;
display:inline-block;
position:absolute;
zoom: 1;
top:0px;
left:0px;
text-align:center;
-webkit-transition: top .3s cubic-bezier(0.165,.84,.44,1);
-webkit-transform: rotate(0deg);
}
#btn-nav:hover > span, #btn-nav.open > span {
top:10px;
}
#btn-nav.open > span:nth-child(1) {
-webkit-animation: rotateAni .2s .1s forwards, expandAni .3s .3s forwards;
}
#btn-nav.open > span:nth-child(2) {
-webkit-animation: rotateAni .2s .1s forwards, expandAni-2 .3s .3s forwards;
}
#btn-nav.open > span:nth-child(3) {
-webkit-animation: rotateAni .2s .1s forwards, expandAni-3 .3s .3s forwards;
}
#-webkit-keyframes rotateAni {
0% {-webkit-transform: rotate(0deg);}
100% {-webkit-transform: rotate(90deg);}
}
#-webkit-keyframes expandAni {
0% {left:0;}
100% {left:-10px;}
}
#-webkit-keyframes expandAni-2 {
0% {left:0;}
100% {left:0px;}
}
#-webkit-keyframes expandAni-3 {
0% {left:0;}
100% {left:10px;}
}
#main-nav {
position:fixed;
left:0;
top:0;
display:block;
width:100%;
height:100%;
z-index:-1;
}
.slice {
width:25%;
height:30%;
min-height:30%;
float:left;
background:black;
opacity:0;
-webkit-transition: 1s;
}
.background {
position:absolute;
left:0;
top:0;
width:100%;
height:100%;
z-index:-1;
}
Managed to do it; deleted the layout and started again.
The main thing was to set overflow hidden on the master div and give it a min-height.
Followed the answers here: Expanding a parent <div> to the height of its children
#master {
background: #000;
height: auto;
min-height: 100%;
overflow: hidden;
position: relative;
width: 100%;
}
#main-nav {
left: 0;
position: absolute;
top: 0;
display: block;
height: 100%;
position: fixed;
width: 100%;
z-index: -1;
}
.slice {
background: #000;
float: left;
height: 33.66%;
opacity: 0;
filter: alpha(opacity=0);
width: 25%;
-webkit-transition: 1s;
}