CSS3 Image sliding starting with invisible image - html

I have this code for my image to nicely slide in to my website from the right side.
img.move
{
position:relative
-webkit-animation-name: image;
-webkit-animation-iteration-count: once;
-webkit-animation-timing-function: ease;
-webkit-animation-duration: 1s;
}
#-webkit-keyframes image {
0% {
right:-708px;
}
100% {
right: 0;
}
}
So right now in my webpage, this image starts in the right side background (it's gray) and ends up in its correct position in the container (it's white). What I want to do (but have no idea how to) is to make the image appear from thin air. What I mean is that it would still have its sliding animation, but it would be invisible on the gray part, and only appear out of white part, like the corner of container was printing it. So I wonder, is there any way I could do it?
Thanks for help
EDIT: JSFIDDLE http://jsfiddle.net/EpCM7/

Okay what I am doing is making the image a child of the div.parent.
Then I apply overflow: hidden; to the parent. When the image slides in from outside of it's parent it will not be visible due to the style.
The html:
<div class="parent">
<img class="move" src="http://vabankbroker.com/templates/vabankbroker/images/2.jpg" style="margin-right: -3px;" />
</div>
The css:
div.parent {
width: 100%;
height: 100%;
overflow: hidden;
}
The Fiddle: JSFIDDLE, remove /show in url to view code
Better Practice
#-webkit-keyframes image {
0% {
left: 100%; /* removes the use of negative values */
}
100% {
left: 0;
}
}

try adding opacity to the animation . might be the effect your looking for
#-webkit-keyframes image {
0% {
opacity: 0;
right:-708px;
}
100% {
opacity: 1;
right: 0;
}
}

Related

How to animate a div through the left side without loosing its content?

.redbox{
width: 100%;
background-color: red;
height: 100px;
animation-name: movereverse;
animation-duration: 5s;
position: relative;
animation-fill-mode:forwards;
animation-direction:normal;
animation-timing-function: ease-in;
overflow: hidden;
}
#keyframes movereverse{
0%{
left: 0;
}
25%{
left:250px;
}
50%{
}
}
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div class="redbox">hello</div>
</body>
</html>
I want to reduce the width of the red box to a certain width through animation. let say, I want to fix the width to 40% but want to show it with the help of animation. I used left property, but it is overflowing through my screen. Is there any way to fix the width to 100 percent and then apply the animation so it does not get overflow and the content remains inside the div.
I think this is what you are looking for but I cannot be sure for sure because I read your question like couple of times and still kind of doesn't make sense
Here:
#keyframes movereverse{
0%{
width: 100%;
left: 0;
}
100%{
width: 40%;
left: 60%;
}
}
Try by take redbox div within other div. And apply style on other div. Both divs (redbox and other) should have position relative.
Maybe it will work.

Overflow hidden for a heading tag not working on mobile browsers, Chrome and Safari. Only works on desktop browsers

screenshots of desktop working vs. mobile not working
I have a code snippet to show what I'm trying to do. I have intentionally set a wider width to a heading that is inside a div containing a slideshow. I want the width of the heading to be clipped by the rounded edge of the image. I have something similar working on desktop browsers, but it doesn't render in Safari or Chrome on my iphone. I had set overflow: hidden to the parent div, which did hide the outer parts of the heading like I intended. But I can't get it to render properly on mobile devices. (Note: overflow hidden is hiding everything in the snippet, and I'm not sure what's going on there either).
I have researched similar questions, but those seem to be dealing with overflow issues concerning the body of an entire page.
div {
position: relative;
/* overflow: hidden; */
}
h3 {
margin: 0;
z-index: 4;
width: 300px;
height: 20px;
position: absolute;
/* top: 150px; */
bottom: 0;
left: 0;
right: 0;
background-color: yellow;
text-align: center;
}
img {
position: absolute;
top: 0;
left: 0;
z-index: 3;
animation: slideshow 12s linear 0s infinite;
border-radius: 25px;
}
img:nth-child(2) {
z-index: 2;
animation-delay: 4s;
}
img:nth-child(3) {
z-index: 1;
animation-delay: 8s;
}
#keyframes slideshow {
25% {
opacity: 1;
}
33.33% {
opacity: 0;
}
91.66% {
opacity: 0;
}
100% {
opacity: 1;
}
}
<div>
<h3>Slideshow</h3>
<img src="http://dummyimage.com/280x200/56AD30/fff.png&text=1" />
<img src="http://dummyimage.com/280x200/1560f0/fff.png&text=2" />
<img src="http://dummyimage.com/280x200/C03229/fff.png&text=3" />
</div>
I see it now that you added the images. You have a margin problem there. The h3 element adds margin. If you add 'margin: 0' to your h3 style you will see what happens. One more thing, you need to remove 'top: 150px;'.
And you have to put some working code next time. In the example you added you cannot see anything at least you add a height value to the main div.

How to achieve a smooth transition of the element going outside the borderline?

I have a container that contains a div inside it. By clicking on that div square, it begins moving and ends up being outside the container.
My problem is that this inner block is being trimmed out really harsh while going beyond the borderline. How could this transition be done more smoothly using CSS means? I want to get an effect when this square disappearing becomes gentle for the eyes.
Maybe I'm supposed to use some kind of an image mask for the main container or a fade effect for the square. I'm not exactly sure how to achieve that behaviour.
Thank you in advance!
Codepan sandbox
.borderline {
position: relative;
text-align: center;
vertical-align: middle;
line-height: 150px;
width: 400px;
height: 150px;
overflow: hidden;
}
.square {
position: absolute;
width: 150px;
height: 150px;
background-color: #0087ff;
}
.square:focus {
transform: translateX(500px);
transition: all 2s;
}
<div class='borderline'>
<div class='square' tabindex="1">Click me</div>
</div>
maybe you could add an animation to your css with opacity like:
.square:focus {
transform: translateX(500px);
transition: all 2s;
animation-name: example;
animation-duration: 1s;
}
#keyframes example {
0% {opacity:1}
50% {opacity:1}
100% {opacity:0}
}
https://codepen.io/anon/pen/rzppON

CSS animation affecting page width

I have an image spinning on my page using CSS animation transforms. The problem is when I reduce the page width I get a horizontal scroll bar that's constantly changing sizes. How can I keep the spinning image but have the parent container cut off the sides when it starts expanding outside of the page width?
I've tried changing the image to a background-image in the rays div but then I lose the effect completely.
See the below minified example.
#rays-container {
width: 100%;
max-width: 490px;
position: absolute;
left: 0;
right: 0;
margin: auto;
z-index: 0;
}
#rays {
width: 100%;
height: 100%;
}
#-webkit-keyframes rays {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
#-ms-keyframes rays {
from {
-ms-transform: rotate(0deg);
}
to {
-ms-transform: rotate(360deg);
}
}
.spin {
-webkit-transform-origin: center center;
-webkit-animation: rays 60s infinite linear;
-ms-animation: rays 60s infinite linear;
-ms-transform-origin: center center;
}
<div id="rays-container" class="spin">
<div id="rays">
<img src="https://s-media-cache-ak0.pinimg.com/736x/af/97/ee/af97eef70a8bce541b19c6a41178a015.jpg" style="width: 100%; height: 100%;">
</div>
</div>
CodePen
The scroll bars you're seeing are because the content inside it is larger than its width (that's the obvious part). That being said, one way of fixing it would be to add overflow-x: hidden; to the CSS of the parent of your element with class="spin", which in this case is the <body>.
body {
overflow-x: hidden;
}
Overflow is the CSS property that defines what will happen if the content doesn't fit. The value hidden tells it to simply clip the content, and not display any scroll bars.
For more info, here's the MDN page on CSS overflow.
Try adding padding to the #rays class, like so.
#rays {
padding: 100px;
/* as suggested by Matheus Avellar */
overflow: hidden;
/* width: 100%; */
/* height: 100%; */
}
Code Pen

Issues with css3 animation on text

i'm building a website and i got some issues with a text slide animation.
here is the fiddle
And here is the animation part :
.slide {
-webkit-animation-name: slide;
-webkit-animation-duration: 1s;
animation-name: slide;
animation-duration: 1s;
}
#-webkit-keyframes slide{
from {
margin-left: 100%;
width: 300%
}
to {
margin-left: 0%;
width: 100%;
}
}
#keyframes slide{
from {
margin-left: 100%;
width: 300%
}
to {
margin-left: 0%;
width: 100%;
}
}
As you can see when the text slides in, the sentence shrinks itself and it doesn't look really smooth. Can someone help me with that ?
I also have a little problem with the blue banner : It looks like it has a margin on the left of like 10px and i can't remove it.
How can i have the banner to take the entire width of the browser ?
This is my first time posting here so if i'm doing something wrong could you tell me please :)
As your div .text has no width assigned, he tries to fit the text inside your div. You can change this by adding a width to your .text:
.text {
width: 100%;
}
Second, the margin you want to avoid is caused by a browser standard for your body tag. You can remove it by adding margin: 0; to it:
body {
margin: 0;
}
You can check your working JS FIDDLE demo. I have added a black background to demonstrate the removed margin.