Here is the code:
HTML:
<div class="connectContainer">
<div class="outerCircle">
<div class="innerCircle">
<div class="imgDiv">
<img class="connectLink" src="car.png">
</div>
</div>
</div>
</div>
CSS:
.connectContainer {
position:relative;
height:200px;
width:200px;
margin-left:auto;
margin-right:auto;
margin-bottom:30px;
margin-top:30px;
}
.imgDiv {
width:150px;
height:150px;
position:absolute;
}
.connectLink {
position:absolute;
height:67px;
width:110px;
top:41px;
left:20px;
}
.innerCircle {
position:absolute;
border:2px solid #43cee6;
width:150px;
height:150px;
border-radius:100%;
left:20px;
top:20px;
-webkit-animation-name: changeInnerBorderColor;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
}
.outerCircle {
position:absolute;
border:2px solid #43cee6;
width:190px;
height:190px;
border-radius:100%;
margin:0 auto;
-webkit-animation-name:changeOuterBorderColor;
-webkit-animation-duration:2s;
-webkit-animation-iteration-count: infinite;
}
I'm using Google Chrome Version 47.0.2526.73 (64-bit).
All the animation and other properties are working absolutely fine.
I tried changing the border-width and it changes as well.
Only the border-radius doesn't work. I'm getting squares instead of circles.
Also, the ionic version of this code for a mobile app gives me the circles!
Please help.
For making any circle you have to change your border-radius property 50% then it will works as circle.
Your .innerCircle and .outerCircle class exists with 100% of border radius value change it to 50% for getting circle.
.innerCircle {
position:absolute;
border:2px solid #43cee6;
width:150px;
height:150px;
border-radius:50%;
left:20px;
top:20px;
-webkit-animation-name: changeInnerBorderColor;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
}
.outerCircle {
position:absolute;
border:2px solid #43cee6;
width:190px;
height:190px;
border-radius:50%;
margin:0 auto;
-webkit-animation-name:changeOuterBorderColor;
-webkit-animation-duration:2s;
-webkit-animation-iteration-count: infinite;
}
This is your fiddle http://jsfiddle.net/7xewv0f5
I see it works normally. Try inspect elements to find other css which is overwriting your border-radius
<div class="connectContainer">
<div class="outerCircle">
<div class="innerCircle">
<div class="imgDiv">
<img class="connectLink" src="car.png">
</div>
</div>
</div>
</div>
Try This in your code to get proper output. you can change top,left,width,height according to your requirement.
.connectContainer {
position: relative;
height: 200px;
width: 200px;
margin-left: auto;
margin-right: auto;
margin-bottom: 30px;
margin-top: 30px;
}
.outerCircle {
position: absolute;
border: 2px solid #43cee6;
width: 190px;
height: 190px;
border-radius: 100%;
margin: 0 auto;
-webkit-animation-name: changeOuterBorderColor;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
}
.innerCircle {
position: absolute;
border: 2px solid #43cee6;
width: 150px;
height: 150px;
border-radius: 100%;
left: 20px;
top: 20px;
-webkit-animation-name: changeInnerBorderColor;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
}
.imgDiv {
width: 150px;
height: 150px;
position: relative;
border-radius: 10px;
}
.connectLink {
position: absolute;
height: 110px;
width: 110px;
top: 20px;
left: 20px;
border-radius: 100%;
}
Related
Originally, just for the logo alone, I used fixed positioning since the divs for each square would not be in the right place otherwise. With a fixed position, they won't go into my inner div box though. The inner and outer div boxes have colour just so I can see them at the moment. Does anyone know of a way to make the position for my divs relative whiel still keeping them in the right position for the animation so they cross over and are symmetrical?
<!DOCTYPE html>
<html>
<head>
<style>
div.outer {
top: 0%;
left: 0%;
margin: 0 auto;
width: 100%;
height: 100%;
position: fixed;
background-color: red;
opacity: 0.5;
}
div.inner {
width: 60%;
height: 60%;
top: 25%;
margin: 0 auto;
position: relative;
background:orange;
}
body {
display: block;
height: 100%;
}
div.a {
width: 200px;
height: 200px;
background-color: blue;
position: relative;
animation-name: raveA;
animation-duration: 2.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}
div.b {
width: 200px;
height: 200px;
background-color: red;
position: relative;
animation-name: raveB;
animation-duration: 2.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}
div.c {
width: 200px;
height: 200px;
background-color: green;
position: relative;
animation-name: raveC;
animation-duration: 2.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}
div.d {
width: 200px;
height: 200px;
background-color: yellow;
position: relative;
animation-name: raveD;
animation-duration: 2.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}
#keyframes raveA {
0% {background-color:blue; left:0px; top:0px;}
50% {background-color:red; left:230px; top:230px;}
100% {background-color:rgb(240,101,43); left:55px; top:20px; transform:skewX(-10deg);}
}
#keyframes raveB {
0% {background-color:red; left:250px; top:250px;}
50% {background-color:yellow; left:20px; top:20px;}
100% {background-color:rgb(247,189,0); left:230px; top:230px; transform:skewX(-10deg);}
}
#keyframes raveC {
0% {background-color:green; left:0px; top:250px;}
50% {background-color:blue; left:230px; top:20px;}
100% {background-color:rgb(0,174,233); left:20px; top:230px; transform:skewX(-10deg);}
}
#keyframes raveD {
0% {background-color:yellow; left:250px; top:0px;}
50% {background-color:green; left:20px; top:230px;}
100% {background-color:rgb(140,189,0); left:265px; top:20px; transform:skewX(-10deg);}
}
</style>
</head>
<body>
<div class="outer">
<div class="inner">
<div class="a"></div>
<div class="b"></div>
<div class="c"></div>
<div class="d"></div>
</div>
</div>
</body>
</html>
I've created an "aquarium" via html and css,
I would like to turn all of the current page to responsive, that will make the "draws" shrink and grow according to the browser resolution.
For start, how the container should look like?
And is it ok to have value like PX inside the primary warp(for example: .Fish or .JellyFish)?
body{
width:100%;
margin:100px auto;
}
div#container{
width:100%;
text-align:center;
}
div.Fish{
position:absolute;
width:200px;
height:120px;
float:left;
}
div.Fish div.fishBody{
width:150px;
height:70px;
border-radius:50%;
border:solid 1px silver;
background-color:silver;
margin: 0 0 0 25px;
}
div.Fish div.fishBody div.fishEye {
float:right;
margin:25px;
width:15px;
height:15px;
border-radius:50%;
background-color:#000000;
}
div.Fish div.fishBody div.fishEye div.fishEyePupil {
float:right;
width:5px;
height:5px;
margin:5px 2px 0 0;
border-radius:50%;
background-color:#fff;
}
div.Fish div.fishMouth{
float:right;
position:relative;
width: 0;
height: 0;
margin:40px 20px 0 0;
border-top: 15px solid transparent;
border-bottom: 15px solid transparent;
border-right: 15px solid #fff;
}
div.Fish div.topFin {
position:relative;
width: 0;
height: 0;
margin:-10px 0 0 70px;
top:10px;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
border-bottom: 30px solid silver;
}
div.Fish div.bottomFin {
position:relative;
width: 0;
height: 0;
margin:0 0 0 70px;
bottom:10px;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
border-top: 30px solid silver;
}
div.Fish div.backFin {
float:left;
position:relative;
width: 0;
height: 0;
margin:35px 0 0 0px;
bottom:10px;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 30px solid silver;
}
.fish1{
left:800px;
top: 300px;
animation: myFishmove1 5s infinite;
animation-direction: alternate;
}
.fish2{
left:1200px;
top: 600px;
animation: myFishmove2 5s infinite;
animation-direction: alternate;
}
.fish3{
left:1600px;
top: 200px;
animation: myFishmove3 5s infinite;
animation-direction: alternate;
}
.fish4{
left:400px;
top: 500px;
animation: myFishmove4 5s infinite;
animation-direction: alternate;
}
#keyframes myFishmove1 {
from {left: 800px;,top:300px;}
to {left:200px;top: 500px;}
}
#keyframes myFishmove2 {
from {left: 1200px;,top:600px;}
to {left:400px;top: 900px;}
}
#keyframes myFishmove3 {
from {left: 1600px;,top:200px;}
to {left:2000px;top: 600px;}
}
#keyframes myFishmove4 {
from {left: 400px;,top:500px;}
to {left:1200px;top: 100px;}
}
div.JellyFish{
position:absolute;
width:250px;
height:600px;
float:left;
}
div.JellyFish div.jellyHead{
width:200px;
height:100px;
background-color:lightblue;
border-top-left-radius: 100px;
border-top-right-radius: 100px;
}
div.JellyFish div.legType1 {
float:left;
width: 40px;
height: 170px;
border-right: solid 8px lightblue;
border-radius: 0 0 50%/100px 100px;
}
div.JellyFish div.legType2 {
margin: 0 0 0 15px;
float:left;
width: 40px;
height: 230px;
border-right: solid 8px lightblue;
border-radius: 0 0 50%/100px 100px;
}
div.JellyFish div.legType3 {
margin: 0 0 0 50px;
float:left;
width: 50px;
height: 120px;
border-left: solid 8px lightblue;
border-radius: 0 0 0 50%/100px;
}
#keyframes myJellymove1 {
from {top: 180px;}
to {top: 400px;}
}
#keyframes myJellymove2 {
from {top: 300px;}
to {top: 600px;}
}
#keyframes myJellymove3 {
from {top: 100px;}
to {top: 700px;}
}
#keyframes myJellymove4 {
from {top: 400px;}
to {top: 800px;}
}
#keyframes myJellymove5 {
from {top: 600px;}
to {top: 200px;}
}
.jelly1{
left:500px;
top:180px;
animation: myJellymove1 5s infinite;
animation-direction: alternate;
}
.jelly2{
left:800px;
top:300px;
animation: myJellymove2 5s infinite;
animation-direction: alternate;
}
.jelly3{
left:1100px;
top:100px;
animation: myJellymove3 5s infinite;
animation-direction: alternate;
}
.jelly4{
left:1400px;
top:400px;
animation: myJellymove4 5s infinite;
animation-direction: alternate;
}
.jelly5{
left:1800px;
top:600px;
animation: myJellymove5 5s infinite;
animation-direction: alternate;
}
<html>
<head>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div id="container">
<div class="Fish fish1">
<div class="backFin"></div>
<div class="fishMouth"></div>
<div class="topFin"></div>
<div class="fishBody">
<div class="fishEye">
<div class="fishEyePupil"></div>
</div>
</div>
<div class="bottomFin"></div>
</div>
<div class="Fish fish2">
<div class="backFin"></div>
<div class="fishMouth"></div>
<div class="topFin"></div>
<div class="fishBody">
<div class="fishEye">
<div class="fishEyePupil"></div>
</div>
</div>
<div class="bottomFin"></div>
</div>
<div class="Fish fish3">
<div class="backFin"></div>
<div class="fishMouth"></div>
<div class="topFin"></div>
<div class="fishBody">
<div class="fishEye">
<div class="fishEyePupil"></div>
</div>
</div>
<div class="bottomFin"></div>
</div>
<div class="Fish fish4">
<div class="backFin"></div>
<div class="fishMouth"></div>
<div class="topFin"></div>
<div class="fishBody">
<div class="fishEye">
<div class="fishEyePupil"></div>
</div>
</div>
<div class="bottomFin"></div>
</div>
<div class="JellyFish jelly1">
<div class="jellyHead"></div>
<div class="legType1"></div>
<div class="legType2"></div>
<div class="legType3"></div>
</div>
<div class="JellyFish jelly2">
<div class="jellyHead"></div>
<div class="legType2" style="margin: 0;"></div>
<div class="legType1"></div>
<div class="legType3"></div>
</div>
<div class="JellyFish jelly3">
<div class="jellyHead"></div>
<div class="legType2" style="margin: 0 50px 0 0;"></div>
<div class="legType3" style="margin: 0 0 0 0;"></div>
<div class="legType1"
style="border-radius: 0 50%/100px 100px 0;border-right:none;border-left:solid 8px lightblue;"></div>
</div>
<div class="JellyFish jelly4">
<div class="jellyHead"></div>
<div class="legType1"></div>
<div class="legType2"></div>
<div class="legType3"></div>
</div>
<div class="JellyFish jelly5">
<div class="jellyHead"></div>
<div class="legType2" style="margin: 0;"></div>
<div class="legType1"></div>
<div class="legType3"></div>
</div>
</div>
</body>
</html>
what is the best option to do that?
Thanks!
As I can see you have used px units to move your objects in keyframes.
Either you should use percentage % based units to move objects.
To make the current page working in all viewports just add:
body{
overflow:none;
}
add the overflow: none property to your body tag to remove horizontal and vertical scrollbars from the page, but your some fishes will be cropped out based on the size of the viewport.
Hope I Helped 😅
I am working on css animation transition.I have div id mybus. It's position is relative. It is the container of multiple divs position relative. I am trying to move the mybus which is the container of all other divs using animation transform: translateX(). It's not woking. (Question is, does position matter while animation?)
I separately applied animation which is transform: rotate() to the div class wheels (It is also inside mybus)which is working well. (I did't include this part of code ) I can give more info about code if needed.
.mybus{
position: relative;
animation-name:busgo;
animation-duration: 10s;
animation-iteration-count: 2;
animation-timing-function: linear;
/* animation-delay: 3s;*/
}
#keyframes busgo{
0%{
transform: translateX(20px);
}
100%{
transform: translateX(-1220px);
}
}
.busBody{
background-color: yellow;
position: absolute;
}
#front{
height:60px;
width:70px;
top:130px;
left:200px;
border-top-left-radius: 5px;
}
#back{
height:90px;
width:200px;
top:100px;
left:270px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.window{
height:20px;
width:30px;
background-color: dimgray;
position: absolute;
border-radius: 2px;
}
#w1{
top:110px;
left:300px;
}
#w2{
top:110px;
left:360px;
}
#w3{
top:110px;
left:420px;
}
<div id="mybus">
<div class="busBody" id="front"></div>
<div class="busBody" id="back"></div>
<div class="window" id="w1"></div>
<div class="window" id="w2"></div>
<div class="window" id="w3"></div>
<div class="wheel" id="wh1"></div>
<div class="wheel" id="wh2"></div>
<div class="headlight"></div>
</div>
You were using .mybus instead of #mybus
#mybus{
position: relative;
animation-name:busgo;
animation-duration: 10s;
animation-iteration-count: 2;
animation-timing-function: linear;
/* animation-delay: 3s;*/
}
#keyframes busgo{
0%{
transform: translateX(20px);
}
100%{
transform: translateX(-1220px);
}
}
.busBody{
background-color: yellow;
position: absolute;
}
#front{
height:60px;
width:70px;
top:130px;
left:200px;
border-top-left-radius: 5px;
}
#back{
height:90px;
width:200px;
top:100px;
left:270px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.window{
height:20px;
width:30px;
background-color: dimgray;
position: absolute;
border-radius: 2px;
}
#w1{
top:110px;
left:300px;
}
#w2{
top:110px;
left:360px;
}
#w3{
top:110px;
left:420px;
}
<div id="mybus">
<div class="busBody" id="front"></div>
<div class="busBody" id="back"></div>
<div class="window" id="w1"></div>
<div class="window" id="w2"></div>
<div class="window" id="w3"></div>
<div class="wheel" id="wh1"></div>
<div class="wheel" id="wh2"></div>
<div class="headlight"></div>
</div>
I want to zoom into a circle(div) until it passes the "camera". I've tried perspective, but that didn't work. At least the way I used it.
Here is my HTML:
:<html>
<body>
<div class="test"></div>
</body>
</html>
Here is my css:
.test{
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
border:2px solid coral;
width:100px;
height:100px;
border-radius:50%;
}
Is there a way to do this ?
This is way how you can do it without any js. But pay attention, adapt .wraper height for your own project.
For example this property helps to remove scrollbars:
overflow: hidden;
Also it's important that parent div need to be relative position and child div - absolute.
.wraper {
position: relative;
width: 100%;
height: 300px;
overflow: hidden;
}
.circle {
width: 30px;
height: 30px;
position: absolute;
top: 50%;
right: 50%;
transform: translateX(50%) translateY(-50%);
border-radius: 50%;
border: 2px solid #000;
animation-name: example;
animation-duration: 15s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
}
#keyframes example {
0% {width: 30px; height: 30px;}
100% {width: 3000px; height: 3000px;}
}
<div class="wraper">
<div class="circle">
</div>
</div>
please try
.test:hover{
transform: scale(1.5);
}
<div class="test"></div>
use
transform: scale(1.5, 1.5);
I have the below hover effect which works well. However, I am trying to add a fixed width of the blue line. For example a max-width of 100px. When I try to amend the code below the animation breaks and doesn't grow from the center.
Any ideas on how to fix the code below so it animates from the center to a fixed width?
body {
width:100%;
}
div {
display:block;
position:absolute;
top:45%;
left:50%;
border-bottom:4px solid blue;
width:0%;
text-align:center;
animation: line 2s linear forwards;
}
#keyframes line {
from {
left:50%;
width:0%;
}
to {
left:5%;
width:90%;
}
}
<div>Heading</div>
Solution 1
Just add an additional span element for which you can limit the width:
body {
width: 100%;
}
div {
display: block;
position: absolute;
top: 45%;
left: 50%;
width: 0%;
animation: line 2s linear forwards;
}
.heading {
display: block;
text-align: center;
max-width: 200px;
border-bottom: 4px solid blue;
margin: 0px auto;
}
#keyframes line {
from {
left: 50%;
width: 0%;
}
to {
left: 5%;
width: 90%;
}
}
<div><span class="heading">Heading</span></div>
Solution 2
Don't use absolute positioning to center your div:
div {
display: block;
width: 0%;
animation: line 2s linear forwards;
text-align: center;
max-width: 200px;
border-bottom: 4px solid blue;
margin: 0px auto;
}
#keyframes line {
from {
width: 0%;
}
to {
width: 90%;
}
}
<div>Heading</div>
I would use the :after pseudo-element instead of adding the border to the actual element. I also reduced your animation time because it seemed a little long:
body {
width:100%;
}
div {
display:inline-block;
position:absolute;
top:45%;
left:50%;
text-align:center;
}
div:hover:after {
content:"";
display:block;
width:0;
margin:0 auto;
height:4px;
background:blue;
animation:line .5s linear forwards;
}
#keyframes line {
from {
width:0%;
}
to {
width:100%;
}
}
<div>Heading</div>
You can also do this without keyframes like this:
body {
width:100%;
}
div {
display:inline-block;
position:absolute;
top:45%;
left:50%;
text-align:center;
}
div:after {
content:"";
display:block;
height:4px;
background:blue;
width:0;
margin:0 auto;
transition:.5s all;
}
div:hover:after {
width:100%;
}
<div>Heading</div>