Hi I'm doing a test site and I have a promotion div with 100% width, one ul with 100% width and 4 li with the products. When it's over 4 li, I want my promo div to have overflow-x: scroll, and my ul will increase its width by 30%. I tried to do with jquery else I think my logic is wrong, any ideas?
JSFiddle: link
Html:
Promotions
-
New York Clock
From R $
79.99For R $ 69,99
-
Dragon Book Door
From R $
69.99For $ 49.99
-
Dragon Book Door
From R $
69.99For $ 49.99
-
Dragon Book Door
From R $
69.99For $ 49.99
-
Dragon Book Door
From R $
69.99For $ 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);
}
}