0
美好的一天!CSS可見性隱藏或摺疊不起作用
我的問題是:即使條件的答案是真的,右箭頭也不會崩潰。它只在將窗口調整爲較小尺寸時才起作用,但當我嘗試將其調整爲較大尺寸時,它不會。
也許我錯過了一些東西。希望你能幫助我。先謝謝你。
這裏的片段(請展開)
$('#left-button').css({visibility: 'collapse'});
$('#right-button').click(function() {
\t event.preventDefault();
\t $('#content').animate({
\t \t scrollLeft: "+=160px"
\t }, "moderate");
});
$('#left-button').click(function() {
\t event.preventDefault();
\t $('#content').animate({
\t \t scrollLeft: "-=160px"
\t }, "moderate");
});
$('#content').scroll(function() {
\t if (this.scrollWidth - $(this).scrollLeft() <= $(this).width() + 0){
\t \t console.log('right end');
\t \t $('#right-button').css({visibility: 'collapse'});
\t \t $('#left-button').css("visibility","visible");
\t }
\t if ($(this).scrollLeft() == 0) {
\t \t console.log('left end');
\t \t $('#right-button').css("visibility","visible");
\t \t $('#left-button').css("visibility","collapse");
\t }
\t if (($(this).scrollLeft() != 0)&&(this.scrollWidth - $(this).scrollLeft() > $(this).width() + 0)) {
\t \t console.log('mid');
\t \t $('#right-button').css("visibility","visible");
\t \t $('#left-button').css("visibility","visible");
\t }
});
.left{
height: 154px;
border: 0;
text-align: right;
}
.right{
height: 154px;
border: 0;
text-align: left;
}
div.internal{
margin-right: 10px;
min-width: 150px;
max-width:150px !important;
min-height: 150px;
max-height:150px;
border-radius: 100%;
border: 2px solid transparent;
padding: 0;
overflow: hidden !important;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
img{
min-width: 146px;
max-width:146px !important;
min-height: 146px;
max-height:146px;
}
div.internal:hover{
border: 2px solid orange;
overflow: hidden !important;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.center{
width: 954px;
height: 152px;
overflow: hidden !important;
/*will change this to hidden later to deny scolling to user*/
white-space: nowrap;
border-radius: 76px 76px 76px 76px;
font-size: 0px;
display: flex;
/*border: 1px solid black;*/
}
#left-button, #right-button{
vertical-align:sub;
font-size: 50px;
font-weight: bolder;
cursor:pointer;
text-align: center;
}
.fa-angle-right,.fa-angle-left{
padding-top:50px;
}
.content{
display: flex;
max-height: 154px;
margin:auto;
text-align: center;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-sm-12 content">
<div class="left">
<span id="left-button">
<i class="fa fa-angle-left" style="float: right"></i>
</span>
</div>
<div class="center" id="content">
<div class="internal">
<img class="" src="https://i0.wp.com/vanillicon.com/655060357b259bcfb74db87a5909097c_200.png">
</div>
<div class="internal">
<img class="" src="https://i0.wp.com/vanillicon.com/655060357b259bcfb74db87a5909097c_200.png">
</div>
<div class="internal">
<img class="" src="https://i0.wp.com/vanillicon.com/655060357b259bcfb74db87a5909097c_200.png">
</div>
<div class="internal">
<img class="" src="https://i0.wp.com/vanillicon.com/655060357b259bcfb74db87a5909097c_200.png">
</div>
<div class="internal">
<img class="" src="https://i0.wp.com/vanillicon.com/655060357b259bcfb74db87a5909097c_200.png">
</div>
<div class="internal">
<img class="" src="https://i0.wp.com/vanillicon.com/655060357b259bcfb74db87a5909097c_200.png">
</div>
<div class="internal">
<img class="" src="https://i0.wp.com/vanillicon.com/655060357b259bcfb74db87a5909097c_200.png">
</div>
<div class="internal">
<img class="" src="https://i0.wp.com/vanillicon.com/655060357b259bcfb74db87a5909097c_200.png">
</div>
<div class="internal">
<img class="" src="https://i0.wp.com/vanillicon.com/655060357b259bcfb74db87a5909097c_200.png">
</div>
</div>
<div class="right">
<span id="right-button">
<i class="fa fa-angle-right" style="float: left"></i>
</span>
</div>
</div>
</div>
謝謝。問題似乎是固定的。 –
好聽!祝你有美好的一天和快樂的編碼 –