【发布时间】:2014-12-04 18:49:57
【问题描述】:
我在div 上有一个过渡宽度规则 -
CSS -
div {
height : 100px ;
width : 0px ;
transition-property: width;
transition-duration: 0.3s;
transition-timing-function: linear;
}
.show {
width : 200px ;
}
HTML -
<div></div>
当我在 show 类上进行切换时,转换发生在 -
增加宽度 - 从左到右,
减小宽度 - 从右到左。
我想这样 -
增加宽度 - 从左到右,
减小宽度 - 从从左到右。
如何实现?
$( document ).ready(function() {
$("#btnShow").click(function () {
$("div").addClass("show");
});
$("#btnHide").click(function () {
$("div").removeClass("show");
});
});
div {
background-color: #b0c4de;
height : 100px ;
width : 0px ;
transition-property: width;
transition-duration: 0.3s;
transition-timing-function: linear;
}
.show {
width : 200px ;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div></div>
<button type="button" id="btnShow">Show</button>
<br>
<button type="button" id="btnHide">Hide</button>
【问题讨论】:
标签: html css css-transitions