auto zoom in n out CSS (apple-like slideshow effect) - html

I like pretty much the slow auto zoom in and out effect on that site : http://watchingtheworldcup.com/ for banner images such as the very top one.
I tired to replicate it, by looking at developer tools wihtin browser, but have some trouble implementing it as in developper tool some mentions are stroked etc.
here is my html :
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<a href="#">
<article class="article_container">
<img class="article_image_hompage5" src="#">
<h2 class="article_title_hompage3"> a favourite thai soup</h2>
</article>
</a>
</div>
</div>
and my css for the image :
.article_image_hompage5{
width: 100%;
border-radius: 2px 2px 2px 2px;
position:relative;
display:block;
margin-left:auto;
margin-right:auto;
margin-top:15px;
z-index:0;
}
Can someone help with with finding the right css settings ?
cheers,

Use css animation you can get the similar result.
/* Chrome, Safari, Opera */
#-webkit-keyframes zoom {
from {
-webkit-transform: scale(1,1);
}
to {
-webkit-transform: scale(1.5,1.5);
}
}
/* Standard syntax */
#keyframes zoom {
from {
transform: scale(1,1);
}
to {
transform: scale(1.5,1.5);
}
}
img {
-webkit-animation: zoom 50s; /* Chrome, Safari, Opera */
animation: zoom 50s;
}
<img alt="" src="http://watchingtheworldcup.com/photos/worldcup1.jpg" />

If you want to also zoom out you need to define the the milestones in your keyframes as such:
#-webkit-keyframes zoominout {
0% {
-webkit-transform: scale(1,1);
}
50% {
-webkit-transform: scale(1.5,1.5);
}
100% {
-webkit-transform: scale(1.1,1.1);
}
}

Use css transform:scale();
like:
JavaScript:
window.onload=function(){
$("#content").fadeOut(4000);
$("#background").addClass("zoom");
setTimeout(function(){
$("#background").removeClass("zoom");
},5000);
}
body{
margin:0px;
padding:0px;
width:100%;
height:100%;
}
#background{
position:absolute;
top:0px;
left:0px;
width:100%;
height:100%;
background:url("http://watchingtheworldcup.com/photos/worldcup1.jpg") center center no-repeat;
background-size: 100% 100%;
display:inline-block;
z-index:2;
transition:all ease 4.1s;
/* transform:scale(1,1);*/
}
#content{
position:absolute;
top:0px;
left:0px;
width:100%;
height:100%;
z-index:3;
background-color:rgba(0,0,0,0.5);
color:#ffffff;
font-size:50px;
}
.zoom{
transform:scale(1.2,1.2);
}
HTML:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<div id="background">
</div>
<div id="content">
<center><br /><br /><br /><br /><br /><br />
Watching...
</center>
</div>

Related

How to acces pseudo element(s) when its sibling is hovered

I have this html code :
<div class="content">
<h2>Hero</h2>
<h2>Hero</h2>
<div class ="tricky"></div>
</div>
where content is a flex container;tricky is another flex container with pseudo elements before and after that i want to use for effects when a is hover.(meaning i got .tricky::before{...} and .tricky::after{..} )
.tricky, .tricky::before, .tricky::after all of them are square width visibility: hidden.
I want when a is hover to affect all tricky's visibility to visible or any other change(ex: color/width/height anything) or one at a time(ex: .content a:hover ~.tricky:before{...})
I tried :
content a:hover ~(or + ).tricky:before { ...} ; content a :hover ~(or +)*{...} and no method works.
Any help?
Thank you.
So i have this:
I want when a is hover to affect tricky's pseudo elements like tricky::before{...} to be able to change his visibility,width,height and same for ::after.
*{
padding:0;
margin:0;
}
.content{
position:relative;
top:200px;
left:300px;
display:flex;
justify-content:center;
align-items:center;
flex-direction:column;
width:150px;
height:150px;
background:transparent;
overflow:hidden;
border-radius:20px;
}
.content::before{
content:"";
position:absolute;
width:100px;
height:250px;
background:linear-gradient(cyan,purple);
animation:4s borderef linear infinite;
}
.content::after{
content:"";
position:absolute;
background:linear-gradient(red,white);
inset:3px;
}
/* hero a(linkul) sta in fata, iar h2 sta in spate*/
.content a{
position:absolute;
color:red;
transform:translate(-50%,0);
-webkit-text-stroke: 1px yellow;
font-size:2.5rem;
text-decoration:none;
z-index:3;
}
.content h2:nth-child(2){
color:blue;
font-size:2.5rem;
animation:animate 4s ease-in-out infinite;
z-index:3;
}
.tricky{
position:absolute;
display:flex;
width:100px;
height:100px;
background:red;
overflow:hidden;
border-radius:20px;
align-items:center;
justify-content:center;
}
.tricky::before{
content:"";
position:absolute;
width:30px;
height:130px;
background:radial-gradient(yellow,cyan);
animation:4s borderef2 linear infinite;
border-radius:20px;
z-index:2;
visibility:hidden;
}
.tricky::after{
content:"";
position:absolute;
background:linear-gradient(yellow,white);
inset:5px;
z-index:2;
visibility:hidden;
}
#ida:hover ~ .tricky::after{
content:"";
background:black;
visibility:visible;
}
#keyframes animate {
0% ,100%
{
clip-path: polygon(0% 45% ,15% 44% ,32% 50%, 54% 60% ,70% 61% ,84% 59%, 100% 52%, 100% 100% ,0% 100%) ;
}
50% {
clip-path: polygon(0% 60% ,16% 65% ,34% 66% ,51% 62% ,67% 50%, 84% 45% ,100% 46%, 100% 100%, 0% 100%) ;
}
}
#keyframes borderef{
0% {
transform:rotate(0deg) ;
}
100%{
transform:rotate(360deg) ;
}
}
#keyframes borderef2{
0% {
transform:rotate(0deg) ;
}
100%{
transform:rotate(-360deg) ;
}
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<link href="test.css" rel="stylesheet"/>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div class="content">
<h2><a id ="ida" href="#">Hero</a></h2>
<h2>Hero</h2>
<div class ="tricky">
</div>
</div>
</body>
</html>
Your question is not very clear. Are you looking for this? The ::after content will show whenever any previous sibling h2 is hovered.
h2:hover~.tricky::after {
content: "123";
}
<div class="content">
<h2>Hero</h2>
<h2>Hero</h2>
<div class="tricky"></div>
</div>
I have used onmouseover and onmouseleave event listener to track the hover and out event and added/removed the visibleAfter class which will take care of the styling of content::after in the CSS
const link = document.getElementById('link');
const tricky = document.getElementById('tricky');
link.addEventListener('mouseover', ()=>{
tricky.classList.add('visibleAfter')
})
link.addEventListener('mouseleave', ()=>{
tricky.classList.remove('visibleAfter')
})
.tricky, .tricky::before, .tricky::after {
width: 50px;
aspect-ratio: 1;
background: #777;
position:relative;
}
.tricky::before, .tricky::after{
content: '';
display:block;
position:absolute;
display:block;
visibility:hidden;
}
.tricky::before{
top:.5em;
left:.5em;
background:red;
}
.tricky::after{
top: 1em;
left:1em;
background:green;
}
.visibleAfter::after {
visibility: unset;
}
<div class="content">
<h2><a id='link' href="#">Hero</a></h2>
<h2>Hero</h2>
<div id='tricky' class="tricky"></div>
</div>
Do you want this? .tricky::after will show on h2's Hover
h2:hover~.tricky::after {
content: "123";
}
<div class="content">
<h2>Hero</h2>
<h2>Hero</h2>
<div class="tricky"></div>
</div>

Guide me with this css animation code technique

Can you tell me what is done by position: numbers % in css animation.
How these numbers are working?
body{
font-family:'Merriweather Sans';
background:white;
}
#test{
background:linear-gradient(270deg, #36bf9c, #368ebf, #df5a5f, #eea965);
color:white;
background-size:600% 600%;
padding:20px 450px;
position:static;
font-size:40px;
font-family:"Merriweather Sans";
animation:gradient 60s ease infinite;
}
#keyframes gradient{
0%{
background-position: 0% 50%;
}
50%{
background-position:100% 50%;
}
100%{
background-position:0% 50%;
}
0% means the CSS will be applied at the start
50% means when half of the specified time will pass ( here 30s)
100% means when the full time passes.
And the animations can't happen instantly so it will go with a lot of transition states but at these times the CSS will be the specified one.
The background-size is 600%, which means 6 times the size of visual area (#test div)it is displayed in. The background is set up as a gradient. By moving this background left to right and back, it makes the colors change in an animated fashion.
I have added an extra div in the example to show the gradient.
body{
font-family:'Merriweather Sans';
background:white;
}
#test{
background:linear-gradient(270deg, #36bf9c, #368ebf, #df5a5f, #eea965);
color:white;
background-size:600% 600%;
padding:20px 450px;
position:static;
font-size:40px;
font-family:"Merriweather Sans";
animation:gradient 60s ease infinite;
}
#backgroundImage {
background:linear-gradient(270deg, #36bf9c, #368ebf, #df5a5f, #eea965);
width:200px;
height:100px;
background-size:100% 100%;
}
#keyframes gradient{
0%{
background-position: 0% 50%;
}
50%{
background-position:100% 50%;
}
100%{
background-position:0% 50%;
}
<div id="test"></div>
<br>
<div id="backgroundImage"></div>

Why is css3 :target not working?

I have a div and I want that on click an other div slides in. I want to achieve this with css3 :target.
Like you can see in the code snippet the :hover works. When hovered an animation start to fade some info in. When you click on the image I want that an other div fades in on the top by calling the same animations as used on hover.
Can somebody help with getting the :target working?
body{
margin: 0px;
}
.image{
position: relative;
width:300px;
height:auto;
}
.image img{
width:100%;
}
.download{
position: absolute;
top:0px;
left:0px;
height:80%;
width:100%;
background-color: gray;
display:none;
}
.info{
position: absolute;
bottom:0px;
left:0px;
height:20%;
width:100%;
background-color: green;
opacity: 0;
}
.info p{
padding: 5px;
margin: 0px;
}
.image:hover .info{
-webkit-animation: show 0.5s; /* Chrome, Safari, Opera */
animation: show 0.5s;
opacity: 1;
}
.image:target .download{
-webkit-animation: show 0.5s; /* Chrome, Safari, Opera */
animation: show 0.5s;
opacity: 1;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes show {
from {opacity: 0;}
to {opacity: 1;}
}
/* Standard syntax */
#keyframes show {
from {opacity: 0;}
to {opacity: 1;}
}
<div class="image"><!-- I detect everything on this div-->
<img src="http://3.bp.blogspot.com/-gaBTIWFTWOo/UTeneLuwWyI/AAAAAAAABJE/E1GQBY4TJ8k/s1600/post-apocalypse-new-york.jpg">
<div class="download"><!-- this div should fade in on click (:target)-->
download
</div>
<div class="info"> <!-- this div should fade in on hover-->
<p>Image 1</p>
</div>
</div>
This can be achieved via jquery: http://jsfiddle.net/swm53ran/13/
$('.image').on('click', function(){
$(this).find('.download').fadeIn(500);
});
i know you want to achieve this with :target, but you can do both animations through jquery to keep consistent if you would like. just another option...
i think i got it the way you wanted with css:
added anchor tag surrounding image, added id #dl to download div...heres the fiddle http://jsfiddle.net/swm53ran/14/
:target {
display:block;
-webkit-animation: show 0.5s; /* Chrome, Safari, Opera*/
animation: show 0.5s;
opacity: 1;
}
<div class="image"><!-- I detect everything on this div-->
<a href="#dl">
<img src="http://3.bp.blogspot.com/-gaBTIWFTWOo/UTeneLuwWyI/AAAAAAAABJE/E1GQBY4TJ8k/s1600/post-apocalypse-new-york.jpg"/>
<div class="download" id="dl"><!-- this div should fade in on click (:target)-->
download
</div>
<div class="info"> <!-- this div should fade in on hover-->
<p>Image 1</p>
</div>
</a>
</div>

Image wont appear in the background

I am trying to show test.png in the background, but it doesn't show up.
Below is what I tried:
HTML:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="menubalkje"></div>
<div class="menu"></div>
<div class="content">
test
</div>
<img class="bgafb" src="images/test.png">
</body>
</html>
CSS:
body {
padding:0px;
margin: 0 auto;
}
.menubalkje{
background-color:#b32b00;
margin-left:auto;
margin-right:auto;
width:1200px;
height:25px;
}
.menu{
background-color:E53700;
margin-left:auto;
margin-right:auto;
width:1200px;
height:75px;
}
.content{
background-color:#ff3e01;
width:1200px;
height:100%;
margin-left:auto;
margin-right:auto;
}
.bgafb{
position:fixed;
left:-270px;
-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
filter: FlipH;
-ms-filter: "FlipH";
}
The img element with id bgafb needs to show the background image, but doesn't.
The image shows for me (I tried with a http url, as I don't have your database)
http://jsfiddle.net/z8dw4Lfz/
<img class="bgafb" src="http://img0.chromatic.io/d8fb8ca6-3b46-d763-9dbf-fd8388402d1d/small.jpg">
probabily you are giving left:-270px; in .bgafb class which is disapearing the image from the screen. if you will set it to left:0px; then image will show in body
Add background property with comma separated values in your CSS like:
#divId {
background:url(images/image1.png) repeat-x, url(images/image2.png) repeat;
}
Hope This Help.
Got Help from HERE:
If you want to use something as a background image, put it in the body of your CSS.
body {
background-image: url('path_to_image');
}

Chrome flashes black screen when using css transition rotate

Transition rotate causes chrome to flash black screen. Is it a Chrome bug (works fine in Safari) or it can be fixed with some clever css.
div {
width:200px;
height:200px;
position:relative;
background:#ddd;
}
span {
display:inline-block;
position:absolute;
top:40px;
left:40px;
width:20px;
background:#007;
height:10px;
-webkit-transition: all .5s;
}
div:hover > span {
-webkit-transform: rotate(180deg);
}
<div>
<span></span>
</div>
Example fiddle here.
The problem with this problem is that it doesn't occur every time so you'll have to hover the gray square several times and you should see the screen blinking in black.
Tested in:
Chrome 16.0.912.75
Chrome Canary 18.0.1010.0
Works fine on:
Safari 5.1.2 (6534.52.7)
All test on Snow Leopard
You can fix this by forcing compositing to stay on by giving -webkit-transform: translate3D(0, 0, 0) to the parent of the transformed element.
div { width:200px; height:200px; position:relative; background:#ddd; -webkit-transform: translate3D(0, 0, 0)}
span { display:inline-block; position:absolute; top:40px; left:40px; width:20px; background:#007; height:10px; -webkit-transition: -webkit-transform .5s; }
div:hover > span { -webkit-transform: rotate(180deg); }
<div>
<span></span>
</div>
Check out the fiddle: http://jsfiddle.net/UHLFF/