2

ここに私がこれまでに持っているものがあります:

JSFiddle

CSS:

#button-top { width: 100px; position: absolute; left: 75%; top: 40px; padding-left: 100px;overflow: hidden;}
#button-top:hover, #button-bottom:hover {cursor: pointer;}
.slide { position: relative; height: 100px; overflow: hidden; width: 350px; }
.slide img {position: relative; z-index: 100;}
.slide p {width: 80px; padding:8px 16px; color: #fff; margin: 0; }
.innerTop, .innerBottom { position: absolute; left: 0; top: 10px; width: 200px; height: 90px; padding: 6px; background: url(http://i39.tinypic.com/nz4ldw.png) 0 0 no-repeat; z-index: 50; display: none; }

#button-bottom { width: 100px; position: absolute; left: 75%; top: 240px; padding-left: 100px;overflow: hidden;}

脚本:

$('#button-top').click(function() {
  $('.innerTop').toggle('slide');
});
$('#button-bottom').click(function() {
  $('.innerBottom').toggle('slide');      
});

HTML:

<div class="hide-mobile" id="button-top">
[IMG]
<div class="slide innerTop"><p>HIDDEN SLIDING CONTENT</p></div>
</div>

<div class="hide-mobile" id="button-bottom">
[IMG]
<div class="slide innerBottom"><p>HIDDEN SLIDING CONTENT</p></div>
</div>

青い内側の div を RIGHT から LEFT にスライドさせたいと思います。

4

2 に答える 2

3

あなたはこれを行うことができます:

// Set the options for the effect type chosen
var options = { direction: 'right' };

// Set the duration (default: 400 milliseconds)
var duration = 700;

$('#button-top').click(function() {
      $('.innerTop').toggle('slide', options, duration);
});
$('#button-bottom').click(function() {
      $('.innerBottom').toggle('slide', options, duration);      
});

FIDDLE DEMO #1またはFIDDLE DEMO #2

于 2013-07-24T08:59:03.417 に答える
3

アニメーション機能を使えば簡単にできます。解決策は次のとおりです。

$('#button-top').toggle(function() {
  $('.innerTop').animate({'left':'3px'});
}, function() {
 $('.innerTop').animate({'left':'103px'});
});


$('#button-bottom').toggle(function() {
  $('.innerBottom').animate({'left':'3px'});
}, function() {
 $('.innerBottom').animate({'left':'103px'});
});

http://jsfiddle.net/nAaMV/6/

于 2013-07-24T04:29:02.843 に答える