【发布时间】:2016-01-14 16:12:11
【问题描述】:
我正在尝试为不同的区域设置动画。观点如下: 有5个区域: A、B、C、D 和 E。
其中 3 个可以同时可见。动画有效,但是当我隐藏必须为 0% 的 2 个区域时,仍然有一条可见的白线。
我尝试使用margin-left: -4px; 修复它,但我认为这不是正确的方法。
在我的示例中,当我关闭 margin-left 时,您可以看到白线。
$('.EditJob').on('click', function(e) {
$('.BNone').toggleClass('BGroot BNone');
$('.CGroot').toggleClass('CKleiner CGroot');
$('.EKlein').toggleClass('ENone EKlein');
$('.ButtonHide').toggleClass('EditJobHide EditJob');
});
$('.CloseWorkItemPreview').on('click', function(e) {
$('.BGroot').toggleClass('BNone BGroot');
$('.CKleiner').toggleClass('CGroot CKleiner');
$('.ENone').toggleClass('EKlein ENone');
$('.ButtonHide').removeClass('EditJobHide');
});
$('.EditQueueItemPreview').on('click', function(e) {
$('.AGroot').toggleClass('AKlein AGroot');
$('.CGroot').toggleClass('CKlein CGroot');
$('.DNone').toggleClass('DGroot DNone');
$('.EKlein').toggleClass('ENone EKlein');
$('.ButtonHide').toggleClass('EditJobHide EditJob');
});
$('.CloseQueueItemPreview').on('click', function(e) {
$('.AKlein').toggleClass('AGroot AKlein');
$('.CKlein').toggleClass('CGroot CKlein');
$('.DGroot').toggleClass('DNone DGroot');
$('.ENone').toggleClass('EKlein ENone');
$('.ButtonHide').removeClass('EditJobHide');
});
.AGroot {
background-color: #90C3D4;
display: inline-block;
height: 960px;
width: 25%;
overflow: hidden;
transition: 3s width linear;
white-space: nowrap;
}
.AKlein {
background-color: #90C3D4;
display: inline-block;
height: 960px;
width: 15%;
overflow: hidden;
transition: 3s width linear;
white-space: nowrap;
}
.BGroot {
background-color: #83CCC8;
display: inline-block;
height: 960px;
width: 60%;
overflow: hidden;
margin-left: -4px;
transition: 3s width linear;
white-space: nowrap;
}
.BNone {
background-color: #83CCC8;
display: inline-block;
height: 960px;
width: 0%;
overflow: hidden;
// margin-left: -4px;
transition: 3s width linear;
white-space: nowrap;
}
.CGroot {
background-color: #83CC89;
display: inline-block;
height: 960px;
width: 60%;
overflow: hidden;
// margin-left: -8px;
transition: 3s width linear;
white-space: nowrap;
}
.CKlein {
background-color: #83CC89;
display: inline-block;
height: 960px;
width: 25%;
overflow: hidden;
margin-left: -8px;
transition: 3s width linear;
white-space: nowrap;
}
.CKleiner {
background-color: #83CC89;
display: inline-block;
height: 960px;
width: 15%;
overflow: hidden;
// margin-left: -4px;
transition: 3s width linear;
white-space: nowrap;
}
.DGroot {
background-color: #CCC383;
display: inline-block;
height: 960px;
width: 60%;
overflow: hidden;
margin-left: -4px;
transition: 3s width linear;
white-space: nowrap;
}
.DNone {
background-color: #CCC383;
display: inline-block;
height: 960px;
width: 0%;
overflow: hidden;
// margin-left: -4px;
transition: 3s width linear;
white-space: nowrap;
}
.EKlein {
background-color: #CCA983;
display: inline-block;
height: 960px;
width: 15%;
overflow: hidden;
// margin-left: -8px;
transition: 3s width linear;
white-space: nowrap;
}
.ENone {
background-color: #CCA983;
display: inline-block;
height: 960px;
width: 0%;
overflow: hidden;
// margin-left: -4px;
transition: 3s width linear;
white-space: nowrap;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="AGroot">
<div class="ButtonHide">
<button class="EditJob">Edit</button>
</div>
Area: A
<p>
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
</p>
<p>
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
</p>
<p>
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
</p>
<p>
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
</p>
</div>
<div class="BNone">
<button class="CloseWorkItemPreview">Close</button>
Area: B
<p>
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
</p>
</div>
<div class="CGroot">
<div class="ButtonHide">
<button class="EditQueueItemPreview">Edit</button>
</div>
Area: C
<p>
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
</p>
</div>
<div class="DNone">
<button class="CloseQueueItemPreview">Close</button>
Area: D
<p>
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
</p>
</div>
<div class="EKlein">
Area: E
<p>
This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.
</p>
</div>
【问题讨论】:
-
我已将您的 Fiddle 代码移动到 Stack Snippet 中,因为 Stack Overflow 要求代码本身包含在问题中(以防链接失效)。