Slider2
by Simon Hi
HTML
<div class="container">
<div class="slider duo">
<img width="240px" height="135px" class="active" src="https://upload.wikimedia.org/wikipedia/commons/7/75/Bicycle-ambulance-russian-empire.jpg">
<img width="240px" height="135px" class="active" src="https://upload.wikimedia.org/wikipedia/commons/1/10/Bicycle%2C_1966_%2849716528817%29.jpg">
</div>
<div class="informations">
<a class="maquette" href="#">
<h1 class='title'>Vélo à vendre. Opportunité!!!</h1>
<p class='category'>Vélos</p>
<p class='price'>0</p>
<p class='date'>2022-01-01</p>
</a>
</div>
</div>
<div class="container">
<div class="slider mono">
<img width="240px" height="135px" class="active" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Apple_Macintosh_512K_Desktop.jpg/320px-Apple_Macintosh_512K_Desktop.jpg">
</div>
<div class="informations">
<a class="maquette" href="#">
<h1 class='title'>Vente d'un ordinateur</h1>
<p class='category'>Informatique</p>
<p class='price'>0</p>
<p class='date'>2022-01-08</p>
</a>
</div>
</div>
<div class="container">
<div class="slider trio">
<img width="240px" height="135px" class="active" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Maison_Carree_in_Nimes_%2816%29.jpg/320px-Maison_Carree_in_Nimes_%2816%29.jpg">
<img width="240px" height="135px" class="active" src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Ch%C3%A2teau_de_Maisons-Laffitte_001.jpg/320px-Ch%C3%A2teau_de_Maisons-Laffitte_001.jpg">
<img width="240px" height="135px" class="active" src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/cd/Ch%C3%A2teau_Chantilly_1.jpg/320px-Ch%C3%A2teau_Chantilly_1.jpg">
</div>
<div class="informations">
<a class="maquette" href="#">
<h1 class='title'>Maison à vendre</h1>
<p class='category'>Immobilier</p>
<p class='price'>0</p>
<p class='date'>2022-01-09</p>
</a>
</div>
</div>
CSS
.container {
max-width: 720px;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: stretch;
margin: 0.25em auto;
border: 1px solid orange;
}
.container>div {
min-width: 240px;
box-sizing: border-box;
}
.slider {
position: relative;
height: 135px;
overflow: hidden;
flex: 1;
}
.slider img {
display: block;
position: absolute;
width: 240px;
height: 135px;
}
.slider.duo img:nth-of-type(1) {
animation: slideinDuo 8s linear infinite;
animation-delay: 4s;
}
.slider.duo img:nth-of-type(2) {
animation: slideinDuo 8s linear infinite;
}
.slider.trio img:nth-of-type(1) {
animation: slideinTrio 12s linear infinite;
animation-delay: 8s;
}
.slider.trio img:nth-of-type(2) {
animation: slideinTrio 12s linear infinite;
animation-delay: 4s;
}
.slider.trio img:nth-of-type(3) {
animation: slideinTrio 12s linear infinite;
}
.informations {
padding: 0.25em;
background: #eee;
width: auto;
flex: 2;
}
.informations a {
text-decoration: none;
color: #000;
}
@keyframes slideinDuo {
from {
top: 0%;
opacity: 1;
}
25% {
top: 0%;
}
50% {
top: 100%;
opacity: 1;
}
74.8% {
top: 200%;
opacity: 0;
}
74.9% {
top: -100%;
opacity: 0
}
75% {
top: -100%;
opacity: 1
}
to {
top: 0%;
opacity: 1
}
}
@keyframes slideinTrio {
from {
top: 0%;
opacity: 1;
}
16.6666% {
top: 0%;
}
33.3333% {
top: 100%;
opacity: 1;
}
83.1111% {
top: 200%;
opacity: 0;
}
83.2222% {
top: -100%;
opacity: 0;
}
83.3333% {
top: -100%;
opacity: 1;
}
to {
top: 0%;
opacity: 1;
}
}
h1 {
font-size: 1.125em;
margin: 0.5em 0;
}
p {
margin: 0.25em 0;
}