Assuming the red box represents my webpages container, and items B,C,D are outside the container. Is it possible to have the items (A,B,C,D...) auto scroll left to right like a carousel using just CSS?
I'm seen examples online on how to do this with images but not with DIVs full of text with a set width?
.container {
margin: 0 auto;
width: 800px;
background: red;
padding: 36px;
box-sizing: border-box;
}
.items {
display: flex;
}
.item {
box-sizing: border-box;
margin-left: 72px;
margin-right: 72px;
padding: 36px;
position: relative;
width: 200px;
min-width: 200px;
background: #efefef;
text-align: center;
border-radius: 4px;
}
<div class="container">
<div class="items">
<div class="item">A</div>
<div class="item">B</div>
<div class="item">C</div>
<div class="item">D</div>
</div>
</div>
Here's a way to do it.
.container {
margin: 0 auto;
background: red;
box-sizing: border-box;
overflow-x: hidden;
}
.items {
min-height: 200px;
position: relative;
}
.item {
box-sizing: border-box;
padding: 36px;
position: absolute;
width: 30%;
background: #efefef;
text-align: center;
border-radius: 4px;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
animation: slide-item 4s infinite;
animation-timing-function: cubic-bezier(.4, 0, .2, 1);
opacity: 0;
}
.item:nth-child(2) { animation-delay: 1s; }
.item:nth-child(3) { animation-delay: 2s; }
.item:nth-child(4) { animation-delay: 3s; }
#keyframes slide-item {
0% { left: 150%; opacity: 1; }
36% { left: 50%; opacity: 1; }
72% { left: -50%; opacity: 1; }
100% { left: -50%; }
}
<div class="container">
<div class="items">
<div class="item">A</div>
<div class="item">B</div>
<div class="item">C</div>
<div class="item">D</div>
</div>
</div>
Related
Trying to create a rotating "card". The cover, inside-left, and inside-right all work fine. The back however is giving me issues. I applied the same rules to each panel so I don't know where the bug is coming from.
.scene {
margin-top: 10em;
margin-left: 20em;
width: 20em;
height: 20em;
perspective: 40em;
}
.cube {
width: 100%;
height: 100%;
position: relative;
animation: spinning 12s infinite;
transform-style: preserve-3d;
transform-origin: left;
}
#keyframes spinning {
from {
transform: translateY(5em) rotateY(0deg);
}
to {
transform: translateY(5em) rotateY(-360deg);
}
}
.front-left {
width: 60%;
height: 100%;
position: absolute;
line-height: 10em;
text-align: center;
transform-origin: left;
}
.panel-1 {
width: 100%;
height: 100%;
border-style: solid;
position: absolute;
backface-visibility: hidden;
}
.cover {
background-color: blue;
}
.left {
background-color: red;
transform: rotateY(180deg);
}
.right-back {
width: 60%;
height: 100%;
position: absolute;
line-height: 10em;
text-align: center;
transform: rotateY(130deg);
transform-origin: left;
}
.panel-2 {
width: 100%;
height: 100%;
border-style: solid;
position: absolute;
backface-visibility: hidden;
}
.end {
background-color: blue;
transform: rotateY(180deg);
}
.right {
background-color: red;
}
<div class="scene">
<div class="cube">
<div class="front-left">
<div class="panel-1 cover">cover</div>
<div class="panel-1 left">inner left</div>
</div>
<div class="right-back">
<div class="panel-2 end">back</div>
<div class="panel-2 right">inner right</div>
</div>
</div>
</div>
here is a fiddle of the code. https://jsfiddle.net/7xtv90as/
I suspect it might be because a transform is applied to the parent container but I am not sure.
.box {
width: 300px;
height: 30px;
display: flex;
justify-content: center;
flex-direction: column;
}
.block1 {
width: 10%;
height: inherit;
background: black;
position: absolute;
animation: boxincrease 2s cubic-bezier(0.74, 0.86, 0.4, 0.92) forwards;
}
#keyframes boxincrease {
0% {
width: 10%;
left: 0;
}
50% {
width: 100%;
left: 0;
}
100% {
width: 0%;
left: 100%;
}
}
<div class="nameintro">
<div class="box">
<div class="block1"></div>
<h1>XYZ<span>.</span></h1>
</div>
<div class="role">
<div class="block2"></div>
<p>AMATEUR ARTIST</p>
</div>
</div>
I want to change the width of the black block as it is covering the whole width of the page i want it to cover only the part where xyz written.
I want to make something like this without using scss.
https://www.youtube.com/watch?v=7d2XsPSjjjI
You need to set the "box" width to fit content so that it doesn't exceed the text and set the position relative to it.
.box {
width: fit-content;
height: 30px;
display: flex;
justify-content: center;
flex-direction: column;
position: relative;
}
.block1 {
height: inherit;
background: black;
position: absolute;
animation: boxincrease 2s cubic-bezier(0.74, 0.86, 0.4, 0.92) forwards;
}
#keyframes boxincrease {
0% {
width: 10%;
left: 0;
}
50% {
width: 100%;
left: 0;
}
100% {
width: 0%;
left: 100%;
}
}
<div class="nameintro">
<div class="box">
<div class="block1"></div>
<h1>XYZ<span>.</span></h1>
</div>
<div class="role">
<div class="block2"></div>
<p>AMATEUR ARTIST</p>
</div>
</div>
Adjust the values in your keyframe,
.box {
width: 300px;
height: 30px;
display: flex;
justify-content: center;
flex-direction: column;
}
.block1 {
width: 10%;
height: inherit;
background: black;
position: absolute;
animation: boxincrease 0.8s cubic-bezier(0.74, 0.86, 0.4, 0.92) forwards;
}
#keyframes boxincrease {
0% {
width: 10%;
left: 0;
}
50% {
width: 15%;
left: 0;
}
100% {
width: 0%;
left: 15%;
}
}
<div class="nameintro">
<div class="box">
<div class="block1"></div>
<h1>XYZ<span>.</span></h1>
</div>
<div class="role">
<div class="block2"></div>
<p>AMATEUR ARTIST</p>
</div>
</div>
I would use a grid and put the blocks in the same grid column example;
.nameintro {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-auto-rows: minmax(30px, auto);
}
.box {
display: grid;
justify-content: center;
grid-template-columns: 300px;
grid-auto-rows: minmax(30px, auto);
}
.one {
grid-column: 1 / 1;
grid-row: 1;
}
.two {
grid-column: 1 / 1;
grid-row: 1;
align-self: center;
justify-self: center;
}
.role {
grid-column: 2 / 2
}
.block1 {
background-color: black;
animation: boxincrease 2s cubic-bezier(0.74, 0.86, 0.4, 0.92) forwards;
}
#keyframes boxincrease {
0% {
width: 10%;
left: 0;
}
50% {
width: 100%;
left: 0;
}
100% {
width: 0%;
left: 100%;
}
}
<div class="nameintro">
<div class="box">
<div class="one block1"></div>
<h1 class="two">XYZ<span>.</span></h1>
</div>
<div class="role">
<div class="block2"></div>
<p>AMATEUR ARTIST</p>
</div>
</div>
I want to place the css animation so it only shows partially on the page.
My problem is that it keeps expanding the page.
I have tried using overflow hidden on .ripple-background but this doesn't work. I have also tried using clip but I don't think this is the right solution unless I am using it wrong.
Can anyone shed some light for me please!
.ripple-background {
position: sticky;
z-index: -1;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 1fr;
justify-items: center;
align-items: center;
height: 610px;
width: 610px;
margin-left: 60%;
margin-top: 50vh;
}
.circle {
position: absolute;
border-radius: 50%;
background: white;
animation: ripple 25s infinite;
box-shadow: 0px 0px 1px 0px #b1b1b1;
}
.small {
width: 100px;
height: 100px;
}
.medium {
width: 200px;
height: 200px;
}
.large {
width: 300px;
height: 300px;
}
.xlarge {
width: 400px;
height: 400px;
}
.xxlarge {
background-color: grey;
width: 500px;
height: 500px;
}
.shade1 {
opacity: 1;
}
.shade2 {
opacity: 0.5;
}
.shade3 {
opacity: 0.7;
}
.shade4 {
opacity: 0.8;
}
.shade5 {
opacity: 0.9;
}
#keyframes ripple {
0% {
transform: scale(0.8);
}
50% {
transform: scale(1.2);
}
100% {
transform: scale(0.8);
}
}
<!-- Animation -->
<div class="ripple-background">
<div class="circle xxlarge shade1"></div>
<div class="circle xlarge shade2"></div>
<div class="circle large shade3"></div>
<div class="circle medium shade4"></div>
<div class="circle small shade5"></div>
</div>
<!-- Animation END-->
For overflow hidden to work, you need it to be on a parent container, with the content inside of it that you want to hide.
Below, I've created a wrapper and set it to be the size of the page.
* {
padding:0;
margin:0;
}
#wrapper {
width: 100vw;
height: 100vh;
overflow:hidden;
}
.ripple-background {
position: sticky;
z-index: -1;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 1fr;
justify-items: center;
align-items: center;
height: 610px;
width: 610px;
margin-left: 60%;
margin-top: 50vh;
}
.circle {
position: absolute;
border-radius: 50%;
background: white;
animation: ripple 25s infinite;
box-shadow: 0px 0px 1px 0px #b1b1b1;
}
.small {
width: 100px;
height: 100px;
}
.medium {
width: 200px;
height: 200px;
}
.large {
width: 300px;
height: 300px;
}
.xlarge {
width: 400px;
height: 400px;
}
.xxlarge {
background-color: grey;
width: 500px;
height: 500px;
}
.shade1 {
opacity: 1;
}
.shade2 {
opacity: 0.5;
}
.shade3 {
opacity: 0.7;
}
.shade4 {
opacity: 0.8;
}
.shade5 {
opacity: 0.9;
}
#keyframes ripple {
0% {
transform: scale(0.8);
}
50% {
transform: scale(1.2);
}
100% {
transform: scale(0.8);
}
}
<!-- Animation -->
<div id='wrapper'>
<div class="ripple-background">
<div class="circle xxlarge shade1"></div>
<div class="circle xlarge shade2"></div>
<div class="circle large shade3"></div>
<div class="circle medium shade4"></div>
<div class="circle small shade5"></div>
</div>
</div>
<!-- Animation END-->
Hi I have two divs side by side - but when I change to mobile view they overlap, how can I stop this? Codepen - https://codepen.io/MarkHarrison/pen/NXNGgJ Thanks
box {
position: absolute !important;
left: 0;}
iframe{
border:10px solid transparent;
border-image-source:url(https://i.imgur.com/91tJ1qi.png);
border-image-slice:10;
width:500px;
height:300px;
display:block;
margin:auto;
}
.box {
position: relative;
margin: 0px;
display: block;
width: 600px;
height: 420px;
margin-top: 15%;
You may simply remove the .box class where there is the absolute position and let bootstrap restruct the content on small screens :
h1,
h2 {
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
h2 {
padding-bottom: 100px;
}
body {
background: #2B2B2B;
}
.neon {
color: #fff;
text-shadow: 0 0 5px #F5D5D5, 0 0 10px #F2A7A7, 0 0 20px #F58484, 0 0 40px #FC5858, 0 0 80px #FF0F0F, 0 0 90px #F5D5D5, 0 0 100px #F2A7A7, 0 0 150px #F58484;
}
iframe {
border: 10px solid transparent;
border-image-source: url(https://i.imgur.com/91tJ1qi.png);
border-image-slice: 10;
width: 500px;
height: 300px;
display: block;
margin: auto;
}
.box {
position: relative;
margin: 0px;
display: block;
width: 600px;
height: 420px;
margin-top: 15%;
}
.face {
position: absolute;
height: 70%;
width: 40%;
left: 30%;
background: #CD853F;
border-radius: 50% 50% 50% 50% / 80% 80% 40% 40%;
}
.face-copy {
position: absolute;
height: 100%;
width: 100%;
background: #CD853F;
border-radius: 50% 50% 50% 50% / 80% 80% 40% 40%;
z-index: 2;
}
.ear-left {
position: absolute;
width: 15%;
height: 20%;
left: 5%;
background: #CD853F;
border-radius: 50% 50% 50% 50% / 50% 50% 90% 90%;
transform: rotate(-60deg);
z-index: 1;
}
.ear-right {
position: absolute;
width: 15%;
height: 20%;
left: 80%;
background: #CD853F;
border-radius: 50% 50% 50% 50% / 50% 50% 90% 90%;
transform: rotate(60deg);
z-index: 1;
}
.ear-inner {
bottom: 20%;
margin-top: 30%;
background: #8B4513;
width: 35%;
height: 80%;
margin-left: 32%;
border-radius: 70% 70%;
}
.eye-left {
position: absolute;
background: white;
width: 15%;
height: 13%;
left: 30%;
top: 30%;
z-index: 2;
border-radius: 50%;
}
.eye-right {
background: white;
width: 15%;
height: 13%;
position: absolute;
left: 55%;
top: 30%;
z-index: 2;
border-radius: 50%;
}
.eye-left-inner,
.eye-right-inner {
background: black;
width: 70%;
height: 70%;
border-radius: 50%;
margin-top: 25%;
z-index: 3;
}
.eye-left-inner {
margin-left: 20%;
}
.eye-right-inner {
margin-left: 10%;
}
.pupil {
position: absolute;
background: white;
width: 30%;
height: 30%;
z-index: 4;
border-radius: 50%;
left: 35%;
}
.nose {
position: absolute;
background: #603311;
width: 50%;
height: 30%;
border-radius: 50%;
margin-left: 25%;
z-index: 4;
margin-top: 65%;
}
.inner-nose {
position: absolute;
width: 85%;
margin-top: 1%;
height: 90%;
background: #8B4513;
border-radius: 50%;
border-top-right-radius: 45%;
transform: rotate(-10deg)
}
.horn-left,
.horn-right {
position: absolute;
margin-left: 15%;
margin-top: -80%;
width: 10%;
height: 80%;
background: #8B4513;
transform: rotate(-20deg);
border-radius: 70% 70% 50% 50% / 50% 50% 50% 50%;
}
.horn-left-bottom,
.horn-left-top,
.horn-left-middle,
.horn-right-bottom,
.horn-right-middle,
.horn-right-top {
background: #8B4513;
position: absolute;
width: 90%;
height: 35%;
transform: rotate(60deg);
margin-top: 500%;
margin-left: 108%;
border-radius: 0.5em 2em 0.5em 2em;
}
.horn-left-top {
margin-top: 20%;
}
.horn-left-middle {
transform: rotate(-60deg);
margin-top: 250%;
margin-left: -110%;
}
.horn-right {
margin-left: 75%;
transform: rotate(21deg);
}
.horn-right-bottom,
.horn-right-top {
background: #8B4513;
transform: rotate(-60deg);
margin-left: -110%;
border-radius: 2em 0.5em 0.5em 2em;
}
.horn-right-top {
margin-top: 20%;
}
.horn-right-middle {
margin-top: 250%;
}
.box {
-webkit-animation: mymove 5s;
/* Safari 4.0 - 8.0 */
animation: mymove 5s;
}
/* Safari 4.0 - 8.0 */
#-webkit-keyframes mymove {
0% {
top: 0px;
}
25% {
top: 200px;
}
75% {
top: 50px
}
100% {
top: 100px;
}
}
/* Standard syntax */
#keyframes mymove {
0% {
top: 0px;
}
25% {
top: 200px;
}
50% {
top: 50px;
}
75% {
top: 150px
}
100% {
top: 0px;
}
}
-moz-animation: cssAnimation 0s ease-in 5s forwards;
/* Firefox */
-webkit-animation: cssAnimation 0s ease-in 5s forwards;
/* Safari and Chrome */
-o-animation: cssAnimation 0s ease-in 5s forwards;
/* Opera */
animation: cssAnimation 0s ease-in 5s forwards;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<h1 class="neon">Welcome to TLW Christmas Countdown</h1>
<h2 class="neon">You Will be taken to your deal shortly!</h2>
</div>
<div class="row">
<div class="col-md-4 blue">
<!--Reindeer-->
<div class="box">
<!--Head -->
<div class="face">
<div class="face-copy"></div>
<div class="ear-left">
<div class="ear-inner"></div>
</div>
<div class="ear-right">
<div class="ear-inner"></div>
</div>
<div class="eye-left">
<div class="eye-left-inner">
<div class="pupil"></div>
</div>
</div>
<div class="eye-right">
<div class="eye-right-inner">
<div class="pupil"></div>
</div>
</div>
<div class="nose">
<div class="inner-nose"></div>
</div>
<div class="horn-left">
<div class="horn-left-bottom"></div>
<div class="horn-left-middle"></div>
<div class="horn-left-top"></div>
</div>
<div class="horn-right">
<div class="horn-right-bottom"></div>
<div class="horn-right-middle"></div>
<div class="horn-right-top"></div>
</div>
<!-- Closing Face -->
</div>
<!-- Closing Box -->
</div>
</div>
<div class="col-md-4 yellow">
<!--Youtube-->
<div class="video" ;>
<iframe width="540" height="285" src="https://www.youtube.com/embed/iDNWwxJonII" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
hey guys I was working on transforms and testing them on overlapping divs and I couldn't make the div that is beneath to transform too
is it possible to do it without any JS?
as you can see the purple div on hover transforms and disappears and I want the red div under it to slightly rotate too and I couldn't make It work
.container {
position: relative;
padding: 2%;
}
.cover {
position: absolute;
top: 13px;
left: 13px;
}
.box1 {
display: inline-block;
width: 200px;
height: 200px;
background-color: red;
}
.box2 {
display: inline-block;
width: 200px;
height: 200px;
background-color: purple;
transition: 2s ease-in-out;
}
.box2:hover {
transform: rotate(35deg);
transition: 2s ease-in-out;
border-radius: 50%;
opacity: 0;
}
<div class="container">
<div class="top">
<div class="box1"></div>
<div class="box1"></div>
</div>
<div class="cover">
<div class="box2"></div>
<div class="box2"></div>
</div>
</div>
Update based on a comment, now using pseudo elements instead of a doubled markup
.container {
padding: 2%;
}
.box {
position: relative;
display: inline-block;
width: 150px;
height: 150px;
}
.box::before,
.box::after {
content: ' ';
position: absolute;
left: 0; top: 0;
height: 100%;
width: 100%;
transition: 2s ease-in-out;
background-color: purple;
}
.box::before {
background: url(http://lorempixel.com/200/200/nature/1);
background-size: cover;
}
.box:hover::before,
.box:hover::after {
transform: rotate(35deg);
transition: 2s ease-in-out;
border-radius: 50%;
opacity: 0;
}
.box:hover::before {
opacity: 0.6;
}
<div class="container">
<div class="top">
<div class="box"></div>
<div class="box"></div>
</div>
</div>
This is what you could do
.container {
width: 500px;
}
.box {
display: inline-block;
position: relative;
}
.box:hover .top,
.box:hover .cover {
transform: rotate(35deg);
transition: 2s ease-in-out;
border-radius: 50%;
opacity: 0;
}
.top {
width: 200px;
height: 200px;
background-color: red;
}
.cover {
position: absolute;
width: 200px;
height: 200px;
background-color: purple;
}
<div class="container">
<div class="box">
<div class="cover"></div>
<div class="top"></div>
</div>
<div class="box">
<div class="cover"></div>
<div class="top"></div>
</div>
</div>
Just brainstorming: How about creating a parent by putting both divs inside a div3, make div3 transparent, position with z-index above the other ones, capturing the hover. Select the other divs then simply as childs of div3:hover.