I am newbie in html and css. Trying to make a portion in my webpage, where i want some image and text to slide up side by side. I used html and css for that.
Here is the link for the code in JSFIDDLE:
Sliding up code
/* Chrome, Safari, Opera */
#-webkit-keyframes mymove {
0% { top: 0%; }
20% { top: -0%; }
25% { top: -20%; }
45% { top: -25%; }
50% { top: -45%; }
70% { top: -50%; }
75% { top: -70%; }
95% { top: -75%; }
100% { top: -100%; }
}
/* Standard syntax */
#keyframes mymove {
0% { top: 0%; }
20% { top: -0%; }
25% { top: -20%; }
45% { top: -25%; }
50% { top: -45%; }
70% { top: -50%; }
75% { top: -70%; }
95% { top: -75%; }
100% { top: -100%; }
}
Actually its sliding up only the images not showing the text. But i need both.
Please check the updated code. Now it works fine.
#image_slider_right {
background-color: #CCFF00;
width: 50%;
float: left;
height: 250px;
margin: 50px 0 0 50px;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymove {
0% {
top: 0%;
}
20% {
top: -0%;
}
25% {
top: -20%;
}
45% {
top: -25%;
}
50% {
top: -45%;
}
70% {
top: -50%;
}
75% {
top: -70%;
}
95% {
top: -75%;
}
100% {
top: -100%;
}
}
/* Standard syntax */
#keyframes mymove {
0% {
top: 0%;
}
20% {
top: -0%;
}
25% {
top: -20%;
}
45% {
top: -25%;
}
50% {
top: -45%;
}
70% {
top: -50%;
}
75% {
top: -70%;
}
95% {
top: -75%;
}
100% {
top: -100%;
}
}
div#sliderup {
overflow: hidden;
position: relative;
height: 100%;
margin-left: 10px;
width: 98%;
}
div#sliderup figure .img_up {
width: 98%;
height: 100%;
float: left;
margin-bottom: 10px;
position: relative;
}
div#sliderup figure {
position: relative;
width: 98%;
margin: 0;
text-align: left;
animation: 20s mymove infinite;
}
.divimgslideup {
float: left;
width: 50%;
}
.divimgslideup_txt {
float: left;
width: 50%;
}
<div id="image_slider_right">
<div id="sliderup">
<figure>
<div class="img_up">
<div class="divimgslideup">
<img src="http://php.quicoto.com/wp-content/uploads/2013/06/css3.jpg" alt="" height="100px" width="100px">
</div>
<div class="divimgslideup_txt">
<strong>Make the Best Choice</strong>
<p>With 17 unique 1, 2 & 3 bedroom floor plans available, tap to find the</p>
</div>
</div>
<div class="img_up">
<div class="divimgslideup">
<img src="http://php.quicoto.com/wp-content/uploads/2013/06/css3.jpg" alt="" height="100px" width="100px">
</div>
<div class="divimgslideup_txt">
<strong>Get Comfortable</strong>
<p>Quality and exceptional value are foundations of our philosophy. Satisfaction with your home is our</p>
</div>
</div>
<figure>
</div>
</div>
</div>
Check the working code on JSFIDDLE
Related
I'm making a carousel of a website but I'm having problem with the width. I want each image to take full width of the viewport but the last image is appearing below the first image. Even the slider animation is not sliding the images properly, by sliding extra content on the right. Any help would be appreciated
/*carousel container*/
.carousel {
overflow: hidden;
}
/*figure tag containing carousel*/
.carousel figure {
position: relative;
width: 600vw;
animation: 25s slider infinite;
}
/*carousel images*/
.carousel figure img {
width: 100vw;
}
/*animations for carousel*/
#keyframes slider {
0% {
left: 0vw;
}
14% {
left: 0vw;
}
15% {
left: -100vw;
}
29% {
left: -100vw;
}
30% {
left: -200vw;
}
44% {
left: -200vw;
}
45% {
left: -300vw;
}
59% {
left: -300vw;
}
60% {
left: -400vw;
}
74% {
left: -400vw;
}
75% {
left: -500vw;
}
90% {
left: -500vw;
}
100% {
left: 0vw;
}
}
<div class="carousel">
<figure>
<img src="https://rukminim1.flixcart.com/flap/1688/280/image/a341a61df77a5715.jpg?q=50">
<img src="https://rukminim1.flixcart.com/flap/1688/280/image/971922653b729a9e.jpg?q=50">
<img src="https://rukminim1.flixcart.com/flap/1688/280/image/4075d3bac7ced1e9.jpg?q=50">
<img src="https://rukminim1.flixcart.com/flap/1688/280/image/411e38f49c1486b4.jpg?q=50">
<img src="https://rukminim1.flixcart.com/flap/1688/280/image/8c30d1a38636e9fa.jpg?q=50">
<img src="https://rukminim1.flixcart.com/flap/1688/280/image/ce435d49852d2b8c.jpg?q=50">
</figure>
</div>
The problem was with the default parameters of the figure tag, which set the spacing between the images. In order to override these rules, add the display: flex and these other rules to the .carousel figure selector.
It should look like this:
.carousel figure {
position: relative;
width: 600vw;
animation: 25s slider infinite;
display: flex;
margin-block-start: 0;
margin-block-end: 0;
margin-inline-start: 0;
margin-inline-end: 0;
}
or like this:
.carousel figure {
position: relative;
width: 600vw;
animation: 25s slider infinite;
display: flex;
margin: 0;
}
/*carousel container*/
.carousel {
overflow: hidden;
}
/*figure tag containing carousel*/
.carousel figure {
position: relative;
width: 600vw;
animation: 25s slider infinite;
display: flex;
margin: 0;
}
/*carousel images*/
.carousel figure img {
width: 100vw;
}
/*animations for carousel*/
#keyframes slider {
0% {
left: 0vw;
}
14% {
left: 0vw;
}
15% {
left: -100vw;
}
29% {
left: -100vw;
}
30% {
left: -200vw;
}
44% {
left: -200vw;
}
45% {
left: -300vw;
}
59% {
left: -300vw;
}
60% {
left: -400vw;
}
74% {
left: -400vw;
}
75% {
left: -500vw;
}
90% {
left: -500vw;
}
100% {
left: 0vw;
}
}
<div class="carousel">
<figure>
<img src="https://rukminim1.flixcart.com/flap/1688/280/image/a341a61df77a5715.jpg?q=50">
<img src="https://rukminim1.flixcart.com/flap/1688/280/image/971922653b729a9e.jpg?q=50">
<img src="https://rukminim1.flixcart.com/flap/1688/280/image/4075d3bac7ced1e9.jpg?q=50">
<img src="https://rukminim1.flixcart.com/flap/1688/280/image/411e38f49c1486b4.jpg?q=50">
<img src="https://rukminim1.flixcart.com/flap/1688/280/image/8c30d1a38636e9fa.jpg?q=50">
<img src="https://rukminim1.flixcart.com/flap/1688/280/image/ce435d49852d2b8c.jpg?q=50">
</figure>
</div>
given this example here
#mainPage {
width: 400px;
height: 165px;
margin: 10% auto;
}
#mainPage>p {
text-align: center;
}
.box {
width: 48px;
height: 30px;
background: red;
}
#title {
letter-spacing: 7px;
font-size: 30px;
margin-bottom: 30px;
}
#box1 {
animation: moveBox1 5s infinite;
}
#box2 {
animation: moveBox2 5s infinite;
}
#keyframes moveBox1 {
from {
/* currentPosition */
}
25% {
/* right top corner */
}
50% {
/* right bottom corner */
}
75% {
/* left bottom corner */
}
to {
/* start position */
}
}
#keyframes moveBox2 {
from {
/* currentPosition */
}
25% {
/* left bottom corner */
}
50% {
/* left top corner */
}
75% {
/* right top corner */
}
to {
/* start position */
}
}
<div id="mainPage">
<div class="box" id="box1"></div>
<p id="title">TITLE HERE</p>
<div class="box" id="box2"></div>
</div>
I want to position box2 to the right side first.
After doing so the two boxes should move around the text clockwise. I tried to start with the animation syntax but I don't know how to position them that they can move around other elements.
So box1 should have this path:
from left top
to right top
to right bottom
to left bottom
back to left top
box2 would have this path:
from right bottom
to left bottom
to left top
to right top
back to right bottom
Could someone help?
Using transform, you can achieve your solution.
#mainPage {
width: 400px;
height: 165px;
margin: 10% auto;
}
#mainPage>p {
text-align: center;
}
.box {
width: 48px;
height: 30px;
background: red;
}
#title {
letter-spacing: 7px;
font-size: 30px;
margin-bottom: 30px;
}
#box1 {
animation: moveBox1 5s infinite;
}
#box2 {
animation: moveBox2 5s infinite;
}
#keyframes moveBox1 {
from {
transform: translate(0, 0);
}
25% {
transform: translate(350px, 0);
}
50% {
transform: translate(350px, 150px);
}
75% {
transform: translate(0, 150px);
}
to {
transform: translate(0, 0);
}
}
#keyframes moveBox2 {
from {
transform: translate(350px, 0);
}
25% {
transform: translate(0, 0);
}
50% {
transform: translate(0, -150px);
}
75% {
transform: translate(350px, -150px);
}
to {
transform: translate(350px, 0);
}
}
<div id="mainPage">
<div class="box" id="box1"></div>
<p id="title">TITLE HERE</p>
<div class="box" id="box2"></div>
</div>
You could use absolute position on red box elements, and then use css animations to change its positions. This will also take box elements out of normal flow of elements.
body {
text-align: center;
}
#element{
text-align: center;
display: inline-block;
position: relative;
margin-top: 30px;
padding: 30px;
}
.box {
width: 48px;
height: 30px;
background: red;
position: absolute;
}
#title {
letter-spacing: 7px;
font-size: 30px;
margin: 0;
}
#box1 {
animation: moveBox1 5s infinite;
top: 0;
left: -48px;
}
#box2 {
animation: moveBox2 5s infinite;
bottom: 0;
right: 48px;
}
#keyframes moveBox1 {
25% {left: 100%; top: 0}
50% {left: 100%; top: calc(100% - 24px)}
75% {left: -48px; top: calc(100% - 24px)}
100% {left: -48px; top: 0}
}
#keyframes moveBox2 {
25% {right: 100%; bottom: 0;}
50% {right: 100%; bottom: calc(100% - 24px);}
75% {right: -48px; bottom: calc(100% - 24px);}
100% {right: -48px; bottom: 0;}
}
<div id="element">
<div class="box" id="box1"></div>
<p id="title">TITLE HERE</p>
<div class="box" id="box2"></div>
</div>
I'm not exactly sure what effect are you looking for but here is exampe of how you might want to position them:
#mainPage {
width: 400px;
height: 165px;
margin: 10% auto;
}
#mainPage>p {
text-align: center;
}
.box {
width: 48px;
height: 30px;
background: red;
position:absolute;
}
#title {
letter-spacing: 7px;
font-size: 30px;
margin-bottom: 30px;
}
#box1 {
animation: moveBox1 5s infinite;
}
#box2 {
animation: moveBox2 5s infinite;
}
#keyframes moveBox1 {
from {
left:170px;
top:30px;
}
25% {
left:500px;
top:30px;
}
50% {
left:500px;
top:135px;
}
75% {
left:170px;
top:135px;
}
to {
left:170px;
top:30px;
}
}
#keyframes moveBox2 {
from {
left:500px;
top:30px;
}
25% {
left:500px;
top:135px;
}
50% {
left:170px;
top:135px;
}
75% {
left:170px;
top:30px;
}
to {
left:500px;
top:30px;
}
}
<div id="mainPage">
<div class="box" id="box1"></div>
<p id="title">TITLE HERE</p>
<div class="box" id="box2"></div>
</div>
<!DOCTYPE html>
<html>
<head>
<style>
.div1 {
width: 100px;
height: 100px;
background: red;
position: relative;
-webkit-animation: myfirst 5s infinite; /* Safari 4.0 - 8.0 */
animation: myfirst 5s infinite;;
}
.div2 {
width: 100px;
height: 100px;
background: red;
position: relative;
-webkit-animation: myfirst 5s infinite; /* Safari 4.0 - 8.0 */
animation: mysecond 5s infinite;;
}
/* Safari 4.0 - 8.0 */
#-webkit-keyframes myfirst {
0% { left: 0px; top: 0px;}
25% { left: 400px; top: 0px;}
50% { left: 400px; top: 400px;}
75% { left: 0px; top: 400px;}
100% { left: 0px; top: 0px;}
}
/* Safari 4.0 - 8.0 */
#-webkit-keyframes mysecond {
0% { left: 400px; top: 200px;}
25% { left: 0px; top: 0px;}
50% { left: 0px; top: -100px;}
75% { left: 400px; top: -100px;}
100% { left: 400px; top: 200px;}
}
#keyframes myfirst {
0% { left: 0px; top: 0px;}
25% { left: 400px; top: 0px;}
50% { left: 400px; top: 400px;}
75% { left: 0px; top: 400px;}
100% { left: 0px; top: 0px;}
}
#keyframes mysecond {
0% { left: 400px; top: 200px;}
25% { left: 0px; top: 200px;}
50% { left: 0px; top: -100px;}
75% { left: 400px; top: -100px;}
100% { left: 400px; top: 200px;}
}
</style>
</head>
<body>
<div class="div1"></div>
<div class="div2"></div>
</body>
So I know very little about coding and was trying to make a html and css only slider. I was able to create a really basic slideshow with three images. However, the code places a white image after the third for some weird reason. Can anyone tell me what I did wrong? Why is there a white page after the last image? Also if possible, how can I make it so that after the last image it doesn't look choppy when it cuts back to the first?
#keyframes slider {
0% {
left: 0;
}
20% {
left: 0;
}
25% {
left: -100%;
}
45% {
left: -100%;
}
50% {
left: -200%;
}
70% {
left: -200%;
}
75% {
left: -300%;
}
95% {
left: -300%;
}
100% {
left: -400%;
}
}
#slider {
overflow: hidden;
width: 60%;
margin: 0 auto;
}
#slider figure img {
width: 20%;
float: left;
}
#slider figure {
position: relative;
width: 500%;
margin: 0;
left: 0;
text-align: left;
font-size: 0;
animation: 15s infinite slider;
}
<div id="slider">
<figure>
<img src="http://thewallpaper.co/wp-content/uploads/2016/03/fire-beach-widescreen-high-definition-wallpaper-pictures-download-full-free-download-wallpaper-high-resolution-colorful-2048x1367-736x459.jpg">
<img src="http://thewallpaper.co/wp-content/uploads/2016/03/awesome-malaysiwide-hdesktop-backgrounphotos-windows-desktop-images-mac-wallpapers-colorful-2048x1367-736x459.jpg">
<img src="https://s-media-cache-ak0.pinimg.com/originals/bf/2e/c5/bf2ec5d03e6ddb65bbff4c98ae367a36.jpg">
</figure>
</div>
</body>
</html>
Since you only have 3 images if you put left: -300%; the last image is out of the container.
Here is the fix:
#keyframes slider {
0% {
left: 0;
}
20% {
left: 0;
}
25% {
left: -100%;
}
45% {
left: -100%;
}
50% {
left: -200%;
}
70% {
left: -200%;
}
75% {
left: 0;
}
95% {
left: 0;
}
100% {
left: 0;
}
}
#slider {
overflow: hidden;
width: 60%;
margin: 0 auto;
}
#slider figure img {
width: 20%;
float: left;
}
#slider figure {
position: relative;
width: 500%;
margin: 0;
left: 0;
text-align: left;
font-size: 0;
animation: 15s infinite slider;
}
<div id="slider">
<figure>
<img src="http://thewallpaper.co/wp-content/uploads/2016/03/fire-beach-widescreen-high-definition-wallpaper-pictures-download-full-free-download-wallpaper-high-resolution-colorful-2048x1367-736x459.jpg">
<img src="http://thewallpaper.co/wp-content/uploads/2016/03/awesome-malaysiwide-hdesktop-backgrounphotos-windows-desktop-images-mac-wallpapers-colorful-2048x1367-736x459.jpg">
<img src="https://s-media-cache-ak0.pinimg.com/originals/bf/2e/c5/bf2ec5d03e6ddb65bbff4c98ae367a36.jpg">
</figure>
</div>
Note that when you are on the last image - the next slide (to the first one) will not be from the right to the left. To get that visual effect you will have to use javascript.
So I have an image slider and it works... kind of. My problem lies that I have 3 images. The slider slides through those images, but when it slides off the 3rd image (last one) it just dissappears, but then it slides back to the first image again? I need it so it slides from the last one to the first one, instead of going invisible for an interval. Here is my code for it currently:
#imgslide {
width: 550px;
height: 300px;
border-radius: 10px;
position: relative;
top: 25%;
left: 50%;
margin-top: -150px;
margin-left: -225px;
overflow: hidden;
}
#imgslide figure img {
width: 20%;
float: left;
}
#imgslide figure {
position: relative;
width: 500%;
margin: 0;
left: 0;
text-align: left;
font-size: 0;
animation: 15s slidy infinite;
}
/* Keyframes */
#keyframes slidy {
0% {
left: 0%;
}
20% {
left: 0%;
}
25% {
left: -100%;
}
45% {
left: -100%;
}
50% {
left: -200%;
}
70% {
left: -200%;
}
75% {
left: -300%;
}
95% {
left: -300%;
}
100% {
left: -400%;
}
}
<div id="imgslide">
<figure>
<img src="http://www.indraneelghosh.com/img/sport/sport_318_test-201.gif" alt="">
<img src="http://www.indraneelghosh.com/img/sport/sport_318_test-201.gif" alt="">
<img src="http://www.indraneelghosh.com/img/sport/sport_318_test-201.gif" alt="">
</figure>
</div>
try this
#imgslide {
width: 450px;
height: 300px;
border-radius: 10px;
position: relative;
top: 25%;
left: 50%;
margin-top: 100px;
margin-left: -225px;
overflow: hidden;
}
#imgslide figure img {
width: 20%;
float: left;
}
#imgslide figure {
position: relative;
width: 500%;
margin: 0;
left: 0;
text-align: left;
font-size: 0;
animation: 15s slidy infinite;
}
/* Keyframes */
#keyframes slidy {
0% {
left: 0%;
}
20% {
left: 0%;
}
25% {
left: -100%;
}
45% {
left: -100%;
}
50% {
left: -200%;
}
70% {
left: -200%;
}
75% {
left: 0%;
}
}
<div id="imgslide">
<figure>
<img src="http://demosthenes.info/assets/images/austin-fireworks.jpg" alt="">
<img src="http://demosthenes.info/assets/images/taj-mahal.jpg" alt="">
<img src="http://demosthenes.info/assets/images/ankor-wat.jpg" alt="">
</figure>
</div>
your images filling only 60% of space(3x 20%), add 2 more images to fill space or stretch your images to 33.33% of width and figure to 300%(adjust animation to 0%,100% and 200%)
Is it possible to create a slider with HTML and CSS?
if yes than how to create a slider using HTML and CSS?
yes try this code . here is a link Simple css slider
html code
#-webkit-keyframes slidy {
0% { left: 0%; }
20% { left: 0%; }
25% { left: -100%; }
45% { left: -100%; }
50% { left: -200%; }
70% { left: -200%; }
75% { left: -300%; }
95% { left: -300%; }
100% { left: -400%; }
}
#keyframes slidy {
0% { left: 0%; }
20% { left: 0%; }
25% { left: -100%; }
45% { left: -100%; }
50% { left: -200%; }
70% { left: -200%; }
75% { left: -300%; }
95% { left: -300%; }
100% { left: -400%; }
}
body {
margin: 0;
}
div#slider {
overflow: hidden;
}
div#slider figure img {
width: 20%;
float: left;
}
div#slider figure {
position: relative;
width: 500%;
margin: 0;
left: 0;
text-align: left;
font-size: 0;
animation: 10s slidy infinite;
/* change this time to reduce time*/
-webkit-animation: 10s slidy infinite;
/* change this time to reduce time*/
}
<div id="slider">
<figure>
<img src="http://demosthenes.info/assets/images/austin-fireworks.jpg" alt="">
<img src="http://demosthenes.info/assets/images/taj-mahal.jpg" alt="">
<img src="http://demosthenes.info/assets/images/ibiza.jpg" alt="">
<img src="http://demosthenes.info/assets/images/ankor-wat.jpg" alt="">
<img src="http://demosthenes.info/assets/images/austin-fireworks.jpg" alt="">
</figure>
</div>
try following link. it is very simple and easy to understand
http://qnimate.com/creating-a-slider-using-html-and-css-only/