4
Hi I’m making a test site and I have a div of promotions with width of 100%, a ul with 100% width and 4 li with the products. When you are more than 4 li, I want my div promotions to overflow-x:scroll, and my ul to increase their width by 30%. I tried to do with jquery but I think my logic is wrong, some idea?
Jsfiddle: https://jsfiddle.net/Lm9n89xg/
Html:
Promotions
-
Clock
New YorkOf R$
79,99For R$ 69,99
-
Porta Livro
DragonOf R$
69.99For R$ 49,99
-
Porta Livro
DragonOf R$
69.99For R$ 49,99
-
Porta Livro
DragonOf R$
69.99For R$ 49,99
-
Porta Livro
DragonOf R$
69.99For R$ 49,99
CSS:
.promoçoes{
width:100%;
height:650px;
margin:0;
padding:0;
background-color:#878787;
}
.promoçoes h1{
font-family:Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", serif;
color:#000000;
text-align:center;
}
.promoçoes ul{
width:100%;
height:600px;
position:relative;
list-style:none;
margin:0;
padding:0;
}
.promoçoes ul li{
display:inline-block;
width:300px;
background-color:#494949;
margin:0;
margin-left:20px;
padding:0;
overflow:hidden;
}
.imageproduct{
width:300px;
height:300px;
}
.promoçoes ul li a{
color:#ccc;
text-decoration:none;
margin:0;
padding:0;
}
.promoçoes ul li a:hover{
color:#BFBE19;
}
.promoçoes h2{
text-align:center;
font-size:25px;
}
.promoçoes h3{
color:#000000;
text-align:center;
}
Jquery:
$(document).ready(function(){
"use strict";
ScrollPromocao();
function ScrollPromocao(){
var $promo = $(".promoçoes");
var $ulPromo = $(".promoçoes ul");
var $liPromo = $(".promoçoes ul li");
var $ulPlus = "30%";
if($ulPromo.width() > $promo.width() && $liPromo.length > 4){
$promo.css('overflow-x', 'scroll');
$ulPromo.css('width', $liPromo.width() * $ulPlus);
}
}
It did help, I reviewed some of my statements and adjusted the problem, thank you
– Leonardo Silva