div 上的 jQuery 动画

标签 jquery html css

我想将 div 元素扩展到左侧,或者扩展到 div 之上。现在它扩展到右侧。我也试图在点击后关闭按钮。我刚刚开始艰苦的类(class),所以很难坚持下去。 这已破了。 broken 这就是我需要的。 fixed

https://jsfiddle.net/GreyFox/01sbv4y2/3/

$(function() {
  var $button = $('.btn2');
  $button.on('click', function(e) {
    $(".sidebar2").animate({
      marginleft: "400px",
      opacity: '0.5',
      height: '150px',
      width: '450px',
      margin: '0'
    });

    if ($(this).html() == 'Close') {
      $(this).html('GET MORE INFO');
    } else {
      $(this).html('Close');
    }
  });
});
.sidebar-wrap {}

.sidebar2 {
  padding-top: 90px;
  padding-left: 5px;
  padding-right: 5px;
  min-height: 308px;
  background-color: #2355ce;
}

.hiddenp {
  display: inline-block;
  min-width: 300px;
  min-height: 300px;
  display: none;
  padding: 20px 20px 20px 20px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="sidewrap" 
  <div class="sidebar2">
    <h2>MOBILE DEVELOPMENT</h2>
    <p>Have business in your pocket!</p>
    <br>
    <a class="btn2" href="#">details</a>
    <p class="hiddenp">selector is used to select the selector is used to select the</p>
  </div>
</div>

最佳答案

看看这个 - https://jsfiddle.net/01sbv4y2/45/

它会按照您的要求向左扩展。

$(function() {
var $button = $('.btn2');
$button.on('click', function(e) {
    $(".sidebar2").animate({        marginRight: "400px",
    opacity: '0.5',
    height: '150px',
    width: '450px',
    margin: '0'
});

    if ($(this).html() == 'Close') {
        $(this).html('GET MORE INFO');
    } else {
        $(this).html('Close');
    }
});

});

关于div 上的 jQuery 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48987427/

相关文章:

html - CSS响应式菜单图标文本

jquery - Django,ajax 用模型数据填充表单

javascript - jquery脚本来选择 previous sibling

javascript - 如何使js成为通过ajax提交的rails表单的格式?

html - 删除 HTML 表格行和列之间的间距

html - 我如何将引导按钮放在另一个相对位置的 div 上?

css - 1200px 网格,两列

javascript - jQuery 自动滚动到最近的部分

html - 如何为元素设置动画,使其在 HTML5 和 CSS3 中的父元素内循环?

javascript - 如果 $count 变量的值为零则隐藏列表元素