Filing stack of images in div - html

I can't fill my images to the single div, stacked all over. It seems like they placed in one line
#keyframes fade {
0% {
opacity: 0;
}
11.11% {
opacity: 1;
}
33.33% {
opacity: 1;
}
44.44% {
opacity: 0;
}
100% {
opacity: 0;
}
}
.fadein {
position: absolute;
height: 200px;
width: 400px;
display: inline-block;
background-size: contain;
overflow: hidden;
border: 4px solid #2e7645;
background-size: cover;
background-position: center;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
/** outline: 1px solid blue; **/
}
.fadein img {
max-width: 100%;
max-height: 100%;
z-index: -1;
position: relative;
left: 0;
right: 0;
opacity: 0;
animation-name: fade;
animation-duration: 9s;
animation-iteration-count: infinite;
}
.fadein img:nth-child(1) {
animation-delay: 0s;
}
.fadein img:nth-child(2) {
animation-delay: 3s;
}
.fadein img:nth-child(3) {
animation-delay: 6s;
}
<div class="fadein">
<img src="http://via.placeholder.com/350x150" style="width:100%">
<img src="http://lorempixel.com/output/animals-q-c-350-150-1.jpg" style="width:100%">
<img src="http://lorempixel.com/output/technics-q-c-350-150-2.jpg" style="width:100%">
</div>
Link to my fiddle

All you need to do is change the position of your img from relative to absolute:
.fadein img
{
...
z-index: -1;
position:absolute; // <-- this is the important change
left:0;
right:0;
...
}

If you also want to fill your container, add after position:absolute (as Niles Tanner mentioned) height and width value as 100%. (BTW you don't need z-index property)
.fadein img
{
max-width: 100%;
max-height:100%;
height:100%;
width:100%;
z-index: -1;
position:absolute;
...
And if your are sure that your pictures have the same dimensions, change your .fadein div's dimension to maintain proportion.
.fadein
{
position:absolute;
height:150px;
width:350px;
...

Related

Problem with Margin on a Loader (Desktop version)

I have a problem with a loader on my home page, I have to use a tablet look for the desktop version, with space on the left and right of the website.
So i used, margin : 0 auto 0 auto for the body on desktop.
The problem is my loader is also following this rule, it's not in the center anymore, I've tried to give it a margin : 0 but doesn't work, I've also tried to give a negative margin, it's moving but it's not really responsive..
If you have any solution, I would appreciate !
I'll provide some pictures so you can understand easier :
.chargement {
width: 100%;
height: 100%;
position: absolute;
animation-name: loading;
animation-duration: 2.5s;
animation-fill-mode: forwards;
}
.chargement_bloc {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.chargement_bloc-cercle {
width: 130px;
height: 130px;
border-radius: 100%;
border: 20px solid #fff;
border-right-color: transparent;
animation-name: circle;
animation-duration: 2.5s;
animation-timing-function: ease-in-out;
visibility: hidden;
}
#keyframes circle {
0% {
visibility: visible;
transform: rotate(0deg);
}
99% {
visibility: visible;
transform: rotate(1500deg);
}
100% {
z-index: -1;
visibility: hidden;
}
}
#keyframes loading {
0% {
background-color: #9356DC;
z-index: 1;
}
99% {
z-index: 1;
background-color: #9356DC;
}
100% {
z-index: -1;
visibility: hidden;
}
}
html {
width: 100%;
}
body {
margin: 0;
}
#media (min-width: 993px) {
body {
width: 993px;
margin: 0 auto 0 auto;
background-color: #5D5D5D;
}
}
<body>
<!-- Barre de chargement -->
<div class="chargement">
<div class="chargement_bloc">
<div class="chargement_bloc-cercle"></div>
</div>
</div>
</body>
The margin is there because on your media-queries you are using min-width So essentially your media-queries are being implemented in your desktop version, which is not what you want. Hence, it is using the width: 993px; you set to it.
I changed min-width to max-width assuming you want the media styles to happen BELOW 993px. max-width: 993px = anything below 993px. So now, between 0-993px screen width, your media queries will take effect. Alternatively, min-width: 993px means anything ABOVE the set range, in this case 993px.
.chargement {
width: 100%;
height: 100%;
position: absolute;
animation-name: loading;
animation-duration: 2.5s;
animation-fill-mode: forwards;
animation-position: center;
}
.chargement_bloc {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.chargement_bloc-cercle {
width: 130px;
height: 130px;
border-radius: 100%;
border: 20px solid #fff;
border-right-color: transparent;
animation-name: circle;
animation-duration: 2.5s;
animation-timing-function: ease-in-out;
visibility: hidden;
}
#keyframes circle {
0% {
visibility: visible;
transform: rotate(0deg);
}
99% {
visibility: visible;
transform: rotate(1500deg);
}
100% {
z-index: -1;
visibility: hidden;
}
}
#keyframes loading {
0% {
background-color: #9356DC;
z-index: 1;
}
99% {
z-index: 1;
background-color: #9356DC;
}
100% {
z-index: -1;
visibility: hidden;
}
}
body {
margin: 0;
}
#media (min-width: 993px) {
body {
width: 993px;
margin: 0 auto 0 auto;
background-color: #5D5D5D;
}
.chargement {
width: 993px;
}
}
<body>
<!-- Barre de chargement -->
<div class="chargement">
<div class="chargement_bloc">
<div class="chargement_bloc-cercle"></div>
</div>
</div>
</body>

I'm attempting to put my logo animation in the center of the page, but the positioning gets all messed up

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>

CSS animation stlye is not working on div element inside flexbox

Can someone please review the following block of code and tell me why the animation on the image div and info div are not working.
this is the html file for the about page. (i had enclosed the block content in a div and given it position relative)
{%extends 'layout.html' %}
{%block content %}
.about {
align-items: center;
top: 5em;
display: flex;
flex-direction: row;
justify-content: center;
box-sizing: border-box;
width: 100%;
max-width: 100%;
}
#image {
animation-name: image2;
animation-duration: 3s;
animation-delay: 3s;
animation-fill-mode: forwards;
}
.image-file {
border: none;
border-radius: 100px;
width: 200px;
height: 200px;
margin-right: 100px;
}
#info {
text-align: center;
max-width: 100%;
-webkit-animation-name: info2;
-webkit-animation-duration: 3s;
-webkit-animation-fill-mode: forwards;
animation-name: info2;
animation-duration: 3s;
animation-fill-mode: forwards;
}
#keyframes image2 {
0% {
left: -100px;
}
100% {
left: 0;
}
}
#-webkit-keyframes info2 {
0% {
right: -100px;
}
100% {
right: 0;
}
}
#keyframes info2 {
0% {
right: -100px;
}
100% {
right: 0;
}
}
<div class='head1'>
<h class='head'>Welcome to the Home page</h>
</div>
<div class='about'>
<div id='image'>
<image class='image-file' src='https://via.placeholder.com/150' alt='nelson'>
</div>
<div id='info'>
<h class='head'>About me</h>
<p class='text'>I am a web developer specialized in vanilla css,<br> html and flask. <br>But i am developing further.</p>
</div>
</div>
Try adding:
#image { position:absolute; }
If you are using Firefox, open the dev tools, locate the div image, and see the styles info.
You will see something like this
Notice that left is grayed. Now, hover on the "i" circle. You will see a message stating "left has no effect because the element is not positioned".
So, this is your problem
.about {
align-items: center;
top: 5em;
display: flex;
flex-direction: row;
justify-content: center;
box-sizing: border-box;
width: 100%;
max-width: 100%;
}
#image {
animation-name: image2;
animation-duration: 3s;
animation-delay: 3s;
animation-fill-mode: forwards;
position: relative; /* added */
}
.image-file {
border: none;
border-radius: 100px;
width: 200px;
height: 200px;
margin-right: 100px;
}
#info {
text-align: center;
max-width: 100%;
-webkit-animation-name: info2;
-webkit-animation-duration: 3s;
-webkit-animation-fill-mode: forwards;
animation-name: info2;
animation-duration: 3s;
animation-fill-mode: forwards;
position: relative; /* added */
}
#keyframes image2 {
0% {
left: -100px;
}
100% {
left: 0;
}
}
#-webkit-keyframes info2 {
0% {
right: -100px;
}
100% {
right: 0;
}
}
#keyframes info2 {
0% {
right: -100px;
}
100% {
right: 0;
}
}
<div class='head1'>
<h class='head'>Welcome to the Home page</h>
</div>
<div class='about'>
<div id='image'>
<image class='image-file' src='https://via.placeholder.com/150' alt='nelson'>
</div>
<div id='info'>
<h class='head'>About me</h>
<p class='text'>I am a web developer specialized in vanilla css,<br> html and flask. <br>But i am developing further.</p>
</div>
</div>

why my second image is not moving or animating

i am trying to animate 2 images:
1.from bottom left to top right.
other from bottom right to top left.
image 1 is moving while the other is not...
1 image is moving (the image from bottom left to top right), the other is still not moving
when i run the code of still image in saprate html filr it runs fine...
<style>
html
{
height:100%
}
body
{
height: 100%;
width:100%;
margin: 0;
background-repeat: no-repeat;
/* background-attachment: fixed;*/
background-image: radial-gradient(black,white);
}
div.move_to_right
{
width: auto;
height: auto;
position: absolute;
left:200px;
/*background-color: black;*/
/* background-image: url('/f16.png');*/
}
.move_to_right{
position: absolute;
left:200px;
}
#move_to_right
{
width: 150px;
height: 150px;
position: relative;
-webkit-animation-name: example; /* Safari 4.0 - 8.0 */
-webkit-animation-duration: 10s; /* Safari 4.0 - 8.0 */
animation-name: example;
animation-duration: 3s;
animation-iteration-count:infinite;
}
.ptag
{
color:white;
}
/* Safari 4.0 - 8.0 */
/* Standard syntax */
#keyframes example {
0%{
opacity: 0.5;
transform: translate(-200px,150px);
}
100%{
opacity: 1;
transform: translate(0px,0px);
}
div.move_to_left
{
width: auto;
height: auto;
position: absolute;
left:200px;
/*background-color: black;*/
/* background-image: url('/f16.png');*/
}
.move_to_left{
position: absolute;
right:200px;
}
#move_to_left
{
width: 150px;
height: 150px;
position: relative;
-webkit-animation-name: example; /* Safari 4.0 - 8.0 */
-webkit-animation-duration: 10s; /* Safari 4.0 - 8.0 */
animation-name: example;
animation-duration: 3s;
animation-iteration-count:infinite;
}
.ptag
{
color:white;
}
/* Safari 4.0 - 8.0 */
/* Standard syntax */
#keyframes example {
0%{
opacity: 0.5;
transform: translate(200px,150px);
}
100%{
opacity: 1;
transform: translate(0px,0px);
}
</style>
<html><body>
<div class="move_to_right">
<!--<img id="move" src="https://pngimage.net/wp-content/uploads/2018/05/f16-png-6.png" style="width:150px; height:150px;">-->
<img id="move_to_right" src="f16.png" style="width:150px; height:150px;">
</div>
<div class="move_to_left">
<!--<img id="move" src="https://pngimage.net/wp-content/uploads/2018/05/f16-png-6.png" style="width:150px; height:150px;">-->
<img id="move_to_left" src="f162.png" style="width:150px; height:150px;">
</div>
</body></html>
Some issues:
you didn't close the #keyframes opening curly brace
both your keyframes had the same name examples
html {
height: 100%
}
body {
height: 100%;
width: 100%;
margin: 0;
background-repeat: no-repeat;
background-image: radial-gradient(black, white);
}
div.move_to_right {
width: auto;
height: auto;
position: absolute;
left: 200px;
}
.move_to_right {
position: absolute;
left: 200px;
}
#move_to_right {
width: 150px;
height: 150px;
position: relative;
-webkit-animation-name: move_to_right;
-webkit-animation-duration: 10s;
animation-name: move_to_right;
animation-duration: 3s;
animation-iteration-count: infinite;
}
#keyframes move_to_right {
0% {
opacity: 0.5;
transform: translate(-200px, 150px);
}
100% {
opacity: 1;
transform: translate(0px, 0px);
}
}
div.move_to_left {
width: auto;
height: auto;
position: absolute;
left: 200px;
}
.move_to_left {
position: absolute;
right: 200px;
}
#move_to_left {
width: 150px;
height: 150px;
position: relative;
-webkit-animation-name: move_to_left;
-webkit-animation-duration: 10s;
animation-name: move_to_left;
animation-duration: 3s;
animation-iteration-count: infinite;
}
#keyframes move_to_left {
0% {
opacity: 0.5;
transform: translate(200px, 150px);
}
100% {
opacity: 1;
transform: translate(0px, 0px);
}
}
<div class="move_to_right">
<img id="move_to_right" src="https://pngimage.net/wp-content/uploads/2018/05/f16-png-6.png" style="width:150px; height:150px;">
</div>
<div class="move_to_left">
<img id="move_to_left" src="https://pngimage.net/wp-content/uploads/2018/05/f16-png-6.png" style="width:150px; height:150px;">
</div>

Jitter on chrome css animations

Trying to make a css animation that fades in on an image from the center by using two centered divs with the same background image [svg], and animating their width and background position. The problem is, on chrome, there's a terrible jitter problem (Maybe from chrome cycling through the animation steps, instead of doing them simultaneously?)
Here's the jsfiddle: http://jsfiddle.net/evankford/s2uRV/4/, where you can see the jitter problem on the left one (which has simultaneous width animation and background-position animation).
Relevant Code (sorry for some leftover stuff from the site it's in)
HTML:
<div class="underheader-wrapper uhw-title">
<div class="underheader uhleft undertitle"> </div>
<div class="underheader uhright undertitle"> </div>
</div>
And CSS:
.undertitle {
-webkit-backface-visibility: hidden;
-webkit-transform: translateZ(0);
background-image:url(http://cereusbright.com/newsite/presskit/images/underheader.svg);
}
.underheader-wrapper {
position: relative;
margin: auto;
width:320px;
height:100px;
}
.underheader {
-webkit-backface-visibility: hidden;
position:absolute;
width: 0px;
height:100px;
opacity: 0;
background-size: 320px 60px;
background-repeat: no-repeat;
-moz-animation-delay: 3s; -webkit-animation-delay:3s;
-moz-animation-duration: 3s; -webkit-animation-duration: 3s;
-moz-animation-name: part1; -webkit-animation-name:part1;
-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards}
.uhleft {
background-position: -160px 40px;
right: 160px;
-webkit-backface-visibility: hidden;
-moz-animation-delay: 3s; -webkit-animation-delay:3s;
-moz-animation-duration: 3s; -webkit-animation-duration: 3s;
-moz-animation-name: part2; -webkit-animation-name:part2;
-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards}
.uhright {
background-position: -160px 40px;
left: 160px;}
#-webkit-keyframes part1 {
from {
width: 0px;
opacity: 0;
}
to {
width: 160px;
opacity: 1;
}}
#-webkit-keyframes part2 {
from {
background-position:-160px 40px;
width: 0px;
opacity: 0;
}
to {
width: 160px;
background-position: 0px 40px;
opacity: 1;
}}
#-moz-keyframes part1 {
from {
width: 0px;
opacity: 0;
}
to {
width: 160px;
opacity: 1;
}}
#-moz-keyframes part2 {
from {
background-position:-160px 40px;
width: 0px;
opacity: 0;
}
to {
background-position: 0px 40px;
width: 160px;
opacity: 1;
}}
Am I stuck with this jitter? I already did a JQuery version, and found people saying that CSS was cleaner/smoother, but the jitter still happens.
Okay, didn't find a way to use dual divs to achieve this goal. Instead, I did something like this.
<div class="outer">
<div class="middle">
<div class"inner">
&nbsp
</div>
</div>
</div>
and then styled them
.outer {
position: relative;
width:321px;
height:100px;
padding: 15px;
}
.middle {
text-align: center;
position: absolute;
left: 160px;
margin:auto;
background-image:url(images/underheader.svg);
background-position:center center;
background-size: 320px 70px;
background-repeat: no-repeat;
/*all the animation stuff */
}
.inner {
position: relative;
display: inline-block;
width: 0px;
height: 100px;
/* all the animation stuff */
}
I then animated the middle div from left:160px to left: 0px and the inner div from width: 0px to width: 320px. I used CSS animation, though it could easily be done with jquery or CSS transitions.
The delay you see on Chrome is given by -webkit-animation-delay:3s;. Change it to -webkit-animation-delay:0s; and you'll see it will start fade in immediately.