http://getbootstrap.com/javascript/#collapse
このメニューを左から右にスライドさせる方法はありますか? 私は周りを見回しましたが、あまり見たことはありませんでしたが、誰かがもう洞察を持っているかどうか疑問に思っていました.
http://getbootstrap.com/javascript/#collapse
このメニューを左から右にスライドさせる方法はありますか? 私は周りを見回しましたが、あまり見たことはありませんでしたが、誰かがもう洞察を持っているかどうか疑問に思っていました.
これも見つけた
http://jc-designs.net/blog/2011/07/how-to-build-a-horizontal-jquery-accordion/
HTML
<div id="accordion">
<div class="panel">
<div class="pink"></div>
<div class="panelContent p1"> <strong>Section 1 Header</strong><br/>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In iaculis volutpat quam, non suscipit arcu accumsan at. Aliquam pellentesque.
</div>
</div>
CSS
#accordion {
list-style:none;
margin:30px 0;
padding:0;
height:270px;
width:980px;
margin:0 0 0 11px;
border-top:2px solid #000000;
border-bottom:2px solid #000000;
overflow:hidden;
}
#accordion .panel {
float:left;
display:block;
height:270px;
width:44px;
overflow:hidden;
color:#666666;
text-decoration:none;
font-size:16px;
line-height:1.5em
}
#accordion .panel.active {
width:848px
}
.panelContent {
padding:15px 15px 15px 55px;
height:240px;
width:778px;
}
.pink {
width:42px;
height:270px;
float:left;
background:url(../images/accordionSprite.png) no-repeat 4px 85px #f980a1;
border-right:2px solid #ffffff;
cursor:pointer
}
.last {
border:none
}
Jクエリ
$(document).ready(function(){
activePanel = $("#accordion div.panel:first");
$(activePanel).addClass('active');
$("#accordion").delegate('.panel', 'click', function(e){
if( ! $(this).is('.active') ){
$(activePanel).animate({width: "44px"}, 300);
$(this).animate({width: "848px"}, 300);
$('#accordion .panel').removeClass('active');
$(this).addClass('active');
activePanel = this;
};
});
});
これは、ターゲット要素の左上からのフェードイン/トグル/スライドを実現するためのシンプルですが効果的な方法です。
提供されているソリューションでは、Bootstrap を使用して例を実行していませんが、Bootstrap 要素と組み合わせてソリューションを使用できます。
そのような、
var main = function() {
var slide = $('.targetEle');
var press = $('button');
press.click(function() {
slide.toggle('slow');
});
}
$(document).ready(main);
.targetEle {
display: none;
margin-top: 5px;
border-radius: 5px;
}
nav {
padding: 5px;
background-color: red;
color: white;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<button class="btn btn-primary" type="button">
Button with target element
</button>
<div class="targetEle">
<nav>
<p>Menu Item</p>
<p>Menu Item</p>
<p>Menu Item</p>
</nav>
</div>
それが役立つことを願っています!