Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comienzo de card con js #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions app/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const flechaDerecha = document.querySelector('.right');
const flechaIzquierda = document.querySelector('.left');
const slaider = document.querySelector('.card__img');
const imagenes = document.querySelector('.img');

flechaDerecha.addEventListener("click",e => moverDerecha());
flechaIzquierda.addEventListener("click",e => moverIzquierda());

let index = 0;//indice
let counter = 0;//contador


function moverDerecha() {
// funcion
counter++;
index = index + 100;
slaider.style.transform = `translate(-${index}%)`;
// condicional
if (counter > slaider.childElementCount - 1 ) {
counter = 0;
index = 0;
slaider.style.transform = `translate(-${index}%)`;
}
return
}


function moverIzquierda() {
counter--;
console.log(counter)
index = index - 100;
slaider.style.transform = `translate(-${index}%)`;
// condicional
if (counter < 0) {
counter = slaider.childElementCount-1;
console.log(counter)
index = 100 * (slaider.childElementCount-1);
slaider.style.transform = `translate(-${index}%)`;
}
return
}

moverDerecha(flechaDerecha);
moverIzquierda(flechaIzquierda);
57 changes: 45 additions & 12 deletions sass/style.css → css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
body {
display: flex;
align-items: center;
background-color: hsl(30, 38%, 92%);
background-color: #000000;
justify-content: center;
width: 100%;
height: 100vh;
Expand All @@ -54,41 +54,74 @@ body {
.main {
width: 90%;
height: 80%;
border-radius: 10px;
background-color: hsl(30, 38%, 92%);
display: flex;
align-items: center;
justify-content: center;
position: relative;
overflow: hidden;
}
.main .card__container {
display: flex;
padding: 20px;
width: 700px;
position: relative;
}
.main .card__container .carrusel {
overflow: hidden;
position: relative;
border-top-right-radius: 0px;
border-top-left-radius: 20px;
border-bottom-left-radius: 20px;
}
.main .card__container .carrusel .row {
z-index: 200;
position: absolute;
width: 30px;
height: 30px;
background-color: rgb(255, 255, 255);
top: 50%;
transform: rotate(45deg);
cursor: pointer;
}
.main .card__container .card__img {
.main .card__container .carrusel .row.left {
left: 20px;
background-color: transparent;
border: solid 2px white;
border-top: none;
border-right: none;
}
.main .card__container .carrusel .row.right {
right: 20px;
background-color: transparent;
border: solid 2px white;
border-left: none;
border-bottom: none;
}
.main .card__container .carrusel .card__img {
display: flex;
flex-wrap: nowrap;
flex-direction: row;
width: 100%;
height: 100%;
position: relative;
transition: transform 0.5s ease;
}
.main .card__container .card__img .img1 {
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
.main .card__container .carrusel .card__img .img {
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
}
.main .card__container .card__img .img2 {
display: none;
}
.main .card__container .card__contend {
padding: 30px;
background-color: hsl(0, 0%, 100%);
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
width: 80%;
display: flex;
align-items: center;
justify-content: space-around;
flex-direction: column;
border-bottom-right-radius: 20px;
border-top-right-radius: 30px;
}
.main .card__container .card__contend .card__text {
position: relative;
Expand Down
1 change: 1 addition & 0 deletions css/style.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added images/imagen1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/imagen2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/imagen3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 12 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<html lang="es">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- displays site properly based on user's device -->
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png" />
<link rel="stylesheet" href="style/style.css">
<link rel="stylesheet" href="css/style.css">
<title>Frontend Mentor | Product preview card component</title>
</head>
<body>
<!-- card -->
<main class="main">
<!-- contend card -->
<div class="card__container">
<div class="card__img">
<img class="img1" src="images/image-product-desktop.jpg">
<img class="img2" src="images/image-product-mobile.jpg">
<div class="carrusel">
<span class="row right" id="flechaizquierda"></span>
<span class="row left" id="flechaderecha"></span>
<div class="card__img">
<img class="img" name="imagen" src="images/image-product-desktop.jpg">
<img class="img" name="imagen" src="images/imagen1.jpg">
<img class="img" name="imagen" src="images/imagen2.jpg">
<img class="img" name="imagen" src="images/imagen3.jpg">
</div>
</div>
<div class="card__contend">
<div class="card__text">
Expand All @@ -34,19 +39,12 @@ <h1 class="tittle">Gabrielle Essence Eau De Parfum</h1>
<span class="card__price-tho">$169.99</span>
</div>
<button class="card__btn">
<img src="../product-preview-card-component-main/images/icon-cart.svg" alt="">
<span>Add to Cart</span>
</button>
</div>
</div>
</main>
<!-- text
<div class="attribution">
Challenge by
<a href="https://www.frontendmentor.io?ref=challenge" target="_blank"
>Frontend Mentor</a
>. Coded by <a href="#">Your Name Here</a>.
</div> -->
<script src="app/main.js"></script>
</body>

</html>
1 change: 0 additions & 1 deletion sass/style.css.map

This file was deleted.

67 changes: 49 additions & 18 deletions sass/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
body{
display: flex;
align-items: center;
background-color: $clr-cream;
background-color: #000000;
justify-content: center;
width: 100%;
height: 100vh;
Expand All @@ -12,42 +12,73 @@ body{
.main{
width: 90%;
height: 80%;
border-radius: 10px;
background-color: $clr-cream;
// background-color: $clr-cream;
display: flex;
align-items: center;
justify-content: center;

position: relative;
overflow: hidden;
.card__container{
display: flex;
padding: 20px;
width: 700px;

.card__img{
width: 100%;
.img1{
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
position: relative;
.carrusel{
overflow: hidden;
position: relative;
border-top-right-radius: 0px;
border-top-left-radius: 20px;
border-bottom-left-radius: 20px;
.row{
z-index: 200;
position: absolute;
width: 30px;
height: 30px;
background-color: rgb(255, 255, 255);
top:50%;
transform: rotate(45deg);
cursor: pointer;
&.left{
left: 20px;
background-color: transparent;
border: solid 2px white;
border-top: none;
border-right: none;
}
&.right{
right: 20px;
background-color: transparent;
border: solid 2px white;
border-left: none;
border-bottom: none;
}
}
.card__img{
display: flex;
flex-wrap: nowrap;
flex-direction: row;
width: 100%;
height: 100%;
object-fit: cover;
}
.img2{
display: none;
position: relative;
transition:transform .5s ease;
.img{
width:100%;
height: 100%;
object-fit: cover;
}
}
}

.card__contend{
padding: 30px;
background-color: $clr-white;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
background-color: $clr-white;
width: 80%;
display: flex;
align-items: center;
justify-content: space-around;
flex-direction: column;

border-bottom-right-radius: 20px;
border-top-right-radius: 30px;
.card__text{
position: relative;
.leyend{
Expand Down
Binary file added slider.zip
Binary file not shown.
Loading