HTML have text be right to a figure with image slider - html

So currently I have an image slider at the left side, but the figure in that slide is set to width: 500%, I want to have text to the right of this figure, but when I try to put text there, it drops down below the image. I need text to the right of the figure image slider and the image on the left side.
#imgslide {
width: 550px;
height: 300px;
position: relative;
overflow: hidden;
}
#imgslide figure img {
opacity: .7;
filter: alpha(opacity=70);
-o-transition: .5s;
-ms-transition: .5s;
-moz-transition: .5s;
-webkit-transition: .5s;
transition: .5s;
width: 20%;
float: left;
border-radius: 10px;
}
#imgslide figure img:hover {
opacity: 1;
filter: alpha(opacity=100);
position: relative;
width: 23%;
display: block;
z-index: 999;
}
#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="https://placeholdit.imgix.net/~text?txtsize=52&txt=550%C3%97300&w=550&h=300" alt="">
<img src="https://placeholdit.imgix.net/~text?txtsize=52&txt=550%C3%97300&w=550&h=300" alt="">
<img src="https://placeholdit.imgix.net/~text?txtsize=52&txt=550%C3%97300&w=550&h=300" alt="">
</figure>
</div>

Add the property to .image-slider.
float: left;
Then create a new div, for example:
<div id="text-container">
<p>
Text example
</p>
</div>
And put the property to .text-container
float:right;

Related

Cannot animate width of an element using CSS Animation

I am using animations in CSS but it is not working. If I check in the inspect menu it is showing invalid syntax even though the syntax is normal. I have other two animations but they are working fine.
Only a particular animation in which I am trying to adjust the width isn't working.
* {
margin: 0;
padding: 0;
}
body {
overflow: hidden;
}
.bg-div {
background: url(imgs/sky.png);
height: 100vh;
background-size: 79% 792px;
background-position-y: -332px;
width: 900vw;
}
.sea-div {
background: url(imgs/sea.jpg);
height: 37vh;
position: absolute;
bottom: 0;
width: 900vw;
background-size: 10% 403px;
}
.bg-ani-class {
animation: seaMove linear infinite 3s;
background-repeat: repeat-x;
}
.sea-ani-class {
animation: seaMove linear infinite 6s;
background-repeat: repeat-x;
}
.obst-ani-class {
animation: obstMove linear 5s;
}
.mountain-div {
position: absolute;
top: 10vh;
/* width: 18vh; */
/* height: 20vh; */
left: 108vw;
}
.mountain-div img {
width: 148vh;
}
.hanuman-div {
position: absolute;
top: 28vh;
left: 3vw;
}
.hanuman-div img {
width: 20vw;
}
#gada {
position: absolute;
left: 0;
/* top: 56px; */
transition: 0.1s ease all;
}
.gada-rot {
left: 8vw !important;
transform: rotate(180deg);
top: -22px !important;
}
.laser {
position: absolute;
transform: rotateZ(189deg);
/* top: -14vh; */
left: 282px;
/* width: 45vw !important; */
width: 0% !important;
/* transition: 0.4s ease-out; */
animation: laserAnimation infinite 3s;
}
.dragon-1-div {}
.dragon-2-div {}
/* Animations */
/* These 2 Animations are working */
#keyframes seaMove {
100% {
transform: translateX(-500vw);
}
}
#keyframes obstMove {
0% {
left: 108vw;
}
100% {
left: -100vw;
}
}
/* This animation isn't working */
#keyframes laserAnimation {
from {
width: 0 !important;
}
to {
width: 45vw !important;
}
}
<div class="bg-div bg-ani-class"></div>
<div class="sea-div sea-ani-class"></div>
<div class="hanuman-div">
<img src="imgs/hanuman.png" alt="">
<img src="imgs/gada.png" alt="" id="gada">
<img src="imgs/laserbeam.png" alt="" class="laser">
</div>
<div class="mountain-div">
<img src="imgs/mountain.png" alt="">
</div>
<div class="dragon-1-div"></div>
<div class="dragon-2-div"></div>
It's generally not a good idea to animate width and height. Always try to use composite animations e.g. opacity, transforms. To achieve width animation use scale transform.
Here is a laser show for you:
body {
overflow: hidden;
}
.laser {
position: absolute;
left: 0;
top: 50%;
height: 10px;
width: 100%;
background: #d7272b;
animation: laserAnimation 2s ease-out infinite;
}
.greenLaser {
position: absolute;
left: 0;
top: 0;
height: 10px;
width: 100%;
background: #0063d5;
animation: laserAnimation 2s ease-out infinite;
}
.blueLaser {
position: absolute;
bottom: 0;
left: 0;
height: 10px;
width: 100%;
background: #00d53b;
animation: laserAnimation 2s ease-out infinite;
}
#keyframes laserAnimation {
from {
transform: scaleX(0);
}
to {
transform: scaleX(1);
}
}
<div class="laser">
</div>
<div class="greenLaser">
</div>
<div class="blueLaser">
</div>

Hover animation "jumps" while hovering out

I want to achive a simple animation on hover in css, but while hovering off, the animation jumps and makes it look silly. Is there a way to avoid that?
My wish would be that it is colapsing the same way it originaly transformed.
Codepen: https://codepen.io/misah/pen/abzRXvL
.item {
width: 20%;
height: 0;
padding-top: 20%;
background-color: blue;
position: relative;
transition: 800ms;
}
.item::after {
position: absolute;
bottom: 0;
height: 30%;
width: 100%;
content: "";
background-color: grey;
transition: transform 800ms ease-in-out;
}
.item:hover::after {
transform: scaleY(2);
transform-origin: bottom;
}
<div class="item">
</div>
This happens because the transform-origin: bottom; is only applied when the item is hovered. When not hovered it falls back to the default - center. Move the rule to the declaration of the ::after.
.item {
width: 20%;
height: 0;
padding-top: 20%;
background-color: blue;
position: relative;
transition: 800ms;
}
.item::after {
position: absolute;
bottom: 0;
height: 30%;
width: 100%;
content: "";
background-color: grey;
transition: transform 800ms ease-in-out;
transform-origin: bottom;
}
.item:hover::after {
transform: scaleY(2);
}
<div class="item"></div>

CSS Animation flickering slightly

I am trying to experiment with CSS Animation and made a simple page transition effect using only Css animation. The problem is when the animation completes, a slight flicker is created. Can you guys suggest some thing to fix this?
Codepen link- https://codepen.io/jake2917/pen/qyzxva?editors=1100
Here is the code.
The problem start when i try to center the h1 tag.
body {
margin: 0;
padding: 0;
}
#line {
border: 0.5px solid #130f40;
opacity: 0;
width: 0;
left: 50%;
transform: translate(-50%, -50%);
position: absolute;
display: block;
top: 50%;
animation-name: run;
animation-duration: 1s;
transition: 0.1s ease-in;
}
#container1 {
width: 100%;
opacity: 0;
background-color: #ff7979;
position: absolute;
top: -110%;
transition: 0.2s ease-in;
animation-name: cover1;
animation-duration: 1s;
animation-delay: 1s;
animation-fill-mode: forwards;
}
#container2 {
width: 100%;
opacity: 0;
background-color: #ff7979;
position: absolute;
bottom: -110%;
transition: 0.2s ease-in;
animation-name: cover2;
animation-duration: 1s;
animation-delay: 1s;
animation-fill-mode: forwards;
}
#keyframes run {
from {
width: 0;
opacity: 0;
}
to {
width: 99%;
opacity: 1;
}
}
#keyframes cover1 {
0% {
top: -10%;
opacity: 0;
height: 0;
}
100% {
top: 0%;
opacity: 1;
height: 50vh;
}
}
#keyframes cover2 {
0% {
bottom: -110%;
opacity: 0;
height: 0;
}
100% {
bottom: 0%;
opacity: 1;
height: 50vh;
}
}
// ADDING THIS LINE MAKE IT FLICKER
#container1 h1 {
text-align: center;
}
<div id="line"></div>
<div id="container1">
<h1>hello there</h1>
</div>
<div id="container2">
<h1>hello there</h1>
</div>
It is flickering left right because you have a content that is more than 100% of the body, html.
In many browsers they are adding a scroll bar and it pushed the content to the left.
What you need to do is to add a simple css code overflow: hidden. This way the content will be hidden, the body remains 100% height and the browser won't add scrollbar;
body {
overflow:hidden;
}

How do I stack images on top of each other wrapped in the same div, and then have them separate with animation when I hover?

HTML:
<div class="mySlides">
<img src="1.jpg">
<img src="2.jpg"/>
<img src="3.jpg"/>
<img src="4.jpg"/>
<img src="5.jpg"/>
</div>
CSS:
.mySlides {
padding-top: 25%;
padding-left: 5%;
}
.mySlides img {
object-fit: cover;
position: absolute;
max-width: 35%;
}
.mySlides img:nth-of-type(1) {
left: 0%;
top: 0%;
-webkit-transform: rotate(5deg);
-moz-transform: rotate(5deg);
-o-transform: rotate(5deg);
transform: rotate(5deg);
}
This will be repeated for all images, i.e. nth-of-type(2,3,4,5)
.mySlides img {
-webkit-transition: all 0.25s ease-out;
-moz-transition: all 0.25s ease-out;
-o-transition: all 0.25s ease-out;
transition: all 0.25s ease-out;
padding: 10px 10px 30px 10px;
background: linear-gradient(#ffffff, #eaeaea);
border: solid 1px black;
}
I wanted to stack the images on top of each other and have them all centered on the screen.
On hovering I wanted the images to separate horizontally while still maintaining the animation.
Check this out
Working fiddler https://jsfiddle.net/RaajNadar/L0ennqwp/
Html
<div class="mySlides">
<img src="http://lorempixel.com/400/200/">
<img src="http://lorempixel.com/400/200/sports"/>
</div>
css
.mySlides {
position: relative;
}
.mySlides img {
position: absolute;
top: 0;
left: 0;
max-width: 300px;
transition: left 1.2s ease-in-out;
}
.mySlides:hover img:last-child {
left: 300px;
}
Also got a nice animation.
Is this what you need?
.mySlides {
display: flex;
position: relative;
}
.mySlides img {
position: absolute;
top: 0;
left: 0;
}
.mySlides:hover img {
position: relative;
top: auto;
left: auto;
}
<div class="mySlides">
<img src="http://placehold.it/300x150/000000">
<img src="http://placehold.it/300x150/003300" />
<img src="http://placehold.it/300x150/00ff00" />
<img src="http://placehold.it/300x150/006600" />
<img src="http://placehold.it/300x150/ff0000" />
</div>

Prevent circular buttons clickable outside circle in Firefox

In Firefox the clickable area of my circular buttons seems to extend outside of the circle in the shape of a square. This does not happen in Chrome/Safari, which display everything properly.
There's a "rotate on hover" feature over the buttons and this glitch is especially evident when hovering diagonally over the bottom left/right corner of the buttons and moving to the center. Anyone have any idea how to fix this?
Test-site: http://parkerrichard.com/new/index.html
HTML
<nav class="centered" role="navigation">
<div class="container">
<div class="centered">
<ul>
<li>
<button class="design"></button>
</li>
<li>
<button class="photo"></button>
</li>
<li>
<button class="music"></button>
</li>
<li>
<button class="art"></button>
</li>
<li>
<button class="parker"></button>
</li>
</ul>
</div>
</div><!--/container -->
</nav><!--/navbar -->
CSS
nav {
margin-top: 20px;
margin-bottom: 80px;
}
nav ul {
list-style: none;
margin: 10px 0 0 -30px;
}
nav li a {
font-size: 25px;
}
nav button {
width: 100%;
opacity: .1;
transition: opacity .7s ease-out;
-moz-transition: opacity .7s ease-out;
-webkit-transition: opacity .7s ease-out;
-o-transition: opacity .7s ease-out;
}
nav button:hover {
opacity: .5;
}
.art:hover, .music:hover, .photo:hover, .design:hover {
-webkit-animation:spin 2s ease;
-moz-animation:spin 2s ease;
animation:spin 2s ease;
}
#-moz-keyframes spin { 10% { -moz-transform: rotate(18deg); } }
#-webkit-keyframes spin { 10% { -webkit-transform: rotate(18deg); } }
#keyframes spin { 10% { -webkit-transform: rotate(18deg); transform:rotate(18deg); } }
nav button {
border-radius:50%;
position: absolute;
opacity: 50% !important;
left: 50%;
right: 50%;
}
.parker {
margin-top: 196px;
margin-left: -100px;
width: 200px;
height: 200px;
background: transparent url('../img/parker.jpg');
background-size: 100%;
opacity: 1 !important;
}
.art {
margin-top: 144px;
margin-left: -150px;
width: 300px;
height: 300px;
background: transparent url('../img/art.jpg');
}
.music {
margin-top: 96px;
margin-left: -198px;
width: 400px;
height: 400px;
background: transparent url('../img/music.jpg');
}
.photo {
margin-top: 48px;
margin-left: -248px;
width: 500px;
height: 500px;
background: transparent url('../img/photo.jpg');
}
.design {
margin-left: -296px;
width: 600px;
height: 600px;
background: transparent url('../img/design.jpg');
}
Firefox seems to have a problem with border-radius on button elements (something which was a problem in webkit browsers in the past aswell, see: Button border radius and cursor). This will probably get fixed in a future version, but I would suggest using divs instead.
The following should work (here also a codepen):
nav {
margin-top: 20px;
margin-bottom: 80px;
}
nav ul {
list-style: none;
margin: 10px 0 0 -30px;
}
nav li a {
font-size: 25px;
}
nav li div {
width: 100%;
opacity: .1;
transition: opacity .7s ease-out;
-moz-transition: opacity .7s ease-out;
-webkit-transition: opacity .7s ease-out;
-o-transition: opacity .7s ease-out;
}
nav li div:hover {
opacity: .5;
}
.art:hover, .music:hover, .photo:hover, .design:hover {
-webkit-animation:spin 2s ease;
-moz-animation:spin 2s ease;
animation:spin 2s ease;
}
#-moz-keyframes spin { 10% { -moz-transform: rotate(18deg); } }
#-webkit-keyframes spin { 10% { -webkit-transform: rotate(18deg); } }
#keyframes spin { 10% { -webkit-transform: rotate(18deg); transform:rotate(18deg); } }
nav li div {
border-radius:50%;
position: absolute;
opacity: 50% !important;
left: 50%;
right: 50%;
}
.parker {
margin-top: 196px;
margin-left: -100px;
width: 200px;
height: 200px;
background: transparent url('http://parkerrichard.com/new/img/parker.jpg');
background-size: 100%;
opacity: 1 !important;
}
.art {
margin-top: 144px;
margin-left: -150px;
width: 300px;
height: 300px;
background: transparent url('http://parkerrichard.com/new/img/art.jpg');
}
.music {
margin-top: 96px;
margin-left: -198px;
width: 400px;
height: 400px;
background: transparent url('http://parkerrichard.com/new/img/music.jpg');
}
.photo {
margin-top: 48px;
margin-left: -248px;
width: 500px;
height: 500px;
background: transparent url('http://parkerrichard.com/new/img/photo.jpg');
}
.design {
margin-left: -296px;
width: 600px;
height: 600px;
background: transparent url('http://parkerrichard.com/new/img/design.jpg');
}
<nav class="centered" role="navigation">
<div class="container">
<div class="centered">
<ul>
<li>
<div class="design"></div>
</li>
<li>
<div class="photo"></div>
</li>
<li>
<div class="music"></div>
</li>
<li>
<div class="art"></div>
</li>
<li>
<div class="parker"></div>
</li>
</ul>
</div>
</div><!--/container -->
</nav><!--/navbar -->