1
I am unable to leave this fluid Carousel, as in the image below the div carousel ul
not picking up 100%
of the div sub-box
which by default has 900px
HTML
<div class="box">
<div class="sub-box">
<h1>
PRINCIPAIS
<div class="b-slide">
<span id="prev"><i class="fas fa-angle-double-left"></i></span>
<span id="next"><i class="fas fa-angle-double-right"></i></span>
</div>
</h1>
<div id="carousel" style="overflow:hidden;">
<ul>
<li><a href=""><div class="destaque">1</div></a></li>
<li><a href=""><div class="destaque">2</div></a></li>
<li><a href=""><div class="destaque">3</div></a></li>
<li><a href=""><div class="destaque">4</div></a></li>
<li><a href=""><div class="destaque">5</div></a></li>
</ul>
</div>
</div><!--sub-box-->
</div><!--box-->
CSS
div{width 100%;}
.box{
float: left;
padding: 01.88888888888889% 01.88888888888889% 0% 01.88888888888889%;
/*padding: 17px 17px 0px 17px;*/
}
.box:first-child{margin: 0%;}
.sub-box{
float: left;
padding: 0% 0% 01.88888888888889% 0%;
border-bottom: 1px solid #e1e1e1;
}
.sub-box:first-child{display: inline-block;margin: 0%;}
#carousel ul{
position: relative;
display: flex;
margin: 0%;
padding: 0%;
float: left;
width: 100%;
max-height: 260px;
height: auto;
background-color: green
}
#carousel ul li{
margin: 0% 01.5% 0% 0%;
width: 16.1%;
/*width: 161px; 161/900*/
background-color: orange
}
#carousel ul li .destaque{
float: left;
width: 100%;
height: 260px;
height: 250px;
border: 1px solid transparent;
border-radius: 3px;
}
#carousel ul li:last-child{margin: 0%;background-color: gray}
JQUERY
$(document).ready(function(){
var speed = 25000;
var run = setInterval('rotate()',speed);
var item_width = $('#carousel li').outerWidth();
var left_value = item_width * (-1);
$('#carousel li:first').before($('#carousel li:last'));
$('#carousel ul').css({'left' : left_value});
$("#prev").click(function(){
var left_intend = parseInt($('#carousel ul').css('left')) + item_width;
$('#carousel ul').animate({'left':left_intend},200, function(){
$('#carousel li:first').before($('#carousel li:last'));
$('#carousel ul').css({'left' : left_value});
});
clearInterval(run);
run = setInterval('rotate()',speed);
});
$("#next").click(function(){
var left_intend = parseInt($('#carousel ul').css('left')) - item_width;
$('#carousel ul').animate({'left':left_intend},200, function(){
$('#carousel li:last').after($('#carousel li:first'));
$('#carousel ul').css({'left' : left_value});
});
clearInterval(run);
run = setInterval('rotate()',speed);
});
$('#carousel').hover(
function(){
clearInterval(run);
disableScroll();
},
function(){
clearInterval(run);
run = setInterval('rotate()',speed);
enableScroll();
});
});
var keys = {37:1, 38:1, 39:1, 40:1};
function preventDefault(e){
e = e || window.event;
if(e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
function preventDefaultForScrollKeys(e){
if(keys[e.keyCode]){
preventDefault(e);
return false;
}
}
function disableScroll(){
window.onwheel = preventDefault;
window.ontouchmove = preventDefault;
document.onkeydown = preventDefaultForScrollKeys;
}
function enableScroll(){
window.onwheel = null;
window.ontouchmove = null;
document.onkeydown = null;
}
function rotate(){
$('#next').click();
}
in fact the #carousel ul
this picking up 100%
of my 900px
only that there’s something pulling her left, I can’t identify, I put margin: 0% 0% 0% 15.77777777777778%;/*margin: 0px 0px 0px 142px; 142/900 */
worked out, more when I’m decreasing the screen, the same effect of the image, the div #carousel ul
back to be pulled left tried to put so
#carousel ul{
position: relative;
display: flex;
align-items: center;
padding: 0px;
float: left;
width: 100%;
height: 260px;
max-height: 260px;
height: auto;
background-color: green
}
and so
#carousel ul{
position: absolute;
top: 35px;
left: 50%;
transform: translate(-50%,0px);
padding: 0px;
float: left;
width: 100%;
height: 260px;
max-height: 260px;
height: auto;
background-color: green
}
no way worked
if anyone has any hiccups that div . highlight stay fluid within 900px also helps
Puts the full CSS so we can reproduce the problem.
– Sam
@Sam opa, blz? ta aqui o problema no jsfiddle https://jsfiddle.net/moya2018/6wyznr01/15/
– goio