CSS を介してホバーで展開する div があります。ユーザーがdivをクリックしたときに、その幅のままにしたい。これまでのところ、私はこれを機能させています。
ただし、ユーザーが div を再度クリック (トグル) したとき、およびユーザーがドキュメントの残りの部分で div をクリックした場合は、div を元のサイズに折りたたむ必要があります。
ここにjQuery:
$(".rail").click(function() {
$(".rail").width( 180 );
});
ここにCSS:
.rail{
width: 30px;
border-left: 10px solid #ff5400;
position: absolute;
top: 0px;
bottom: 0px;
right: 0px;
background-color: rgba(0,0,0,0.15);
cursor: pointer;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
}
.rail:hover{
width: 180px;
background-color: #ddd;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
}