可扩展的缩略图网格Twitter Bootstrap

时间:2015-05-14 18:49:45

标签: javascript jquery html css twitter-bootstrap

好的,所以我在这里使用了各种各样的插件来解决这个问题。我和我的客户一起检查了这个页面几个小时。他说他不想让我使用插件。他引用了jQuery Animate,但我是一个写自己的代码的菜鸟我不知道从哪里开始。我提供了一个我需要它做什么和看起来像的图像,但我需要一些帮助找到解决方案。感谢您的所有帮助和时间!)

我需要补充的是,描述将始终直接在领导缩略图下展开。我希望它对移动用户来说也是无能为力的。如果可能的话?

enter image description here

<div class="container leaderShipwrapper gallery-items">
    <ul id="items" class="row list-unstyled">
        <div class="col-sm-12 col-sm-offset-1 leaderShipgrid">
            <li class="col-sm-2 col-xs-4 leader" data-name="joe" data-title="developer" data-profile="profile"><a href="#"><img class="image-responsive" src="images/leader.jpg" alt="" /></a></li>
            <li class="col-sm-2 col-xs-4 leader" data-name="ray" data-title="dunce" data-profile="dunce profile"><a href="#"><img class="image-responsive" src="images/leader.jpg" alt="" /></a></li>
            <li class="col-sm-2 col-xs-4 leader" data-name="joe" data-title="developer" data-profile="profile"><a href="#"><img class="image-responsive" src="images/leader.jpg" alt="" /></a></li>
            <li class="col-sm-2 col-xs-4 leader" data-name="joe" data-title="developer" data-profile="profile"><a href="#"><img class="image-responsive" src="images/leader.jpg" alt="" /></a></li>
            <li class="col-sm-2 col-xs-4 leader" data-name="joe" data-title="developer" data-profile="profile"><a href="#"><img class="image-responsive" src="images/leader.jpg" alt="" /></a></li>
        </div>
        <div class="col-sm-10 col-sm-offset-1">
            <li id="1" class="leaderDescription"><div class="leaderName">NAME</div><div class="leaderTitle">TITLE</div><div class="leaderProfile">Description for row 1 cell 1</div></li>
        </div>
    </ul>
</div>

$(document).ready(function() {
            $('.navbar .dropdown').hover(function() {
          $(this).find('.hover-dropdown').first().stop(true, true).slideDown(150);
        }, function() {
          $(this).find('.hover-dropdown').first().stop(true, true).slideUp(105)
        });

        $('.leader').click(function(){
    $(this).parent().siblings().find('.leaderDescription').find('.leaderName').text($(this).attr('data-name'));
    $(this).parent().siblings().find('.leaderDescription').find('.leaderTitle').text($(this).attr('data-title'));
    $(this).parent().siblings().find('.leaderDescription').find('.leaderProfile').text($(this).attr('data-profile'));
    $(this).parent().siblings().find('.leaderDescription').slideDown();
    });

    });

好的,所以我现在很好地问这个问题。我需要知道我需要做些什么来使它更接近上面的图像。我有第一行,我正在获取数据正确加载我只是不能滑动,如果一个已经打开然后向下滑动被点击的新的。我还需要它来打开领导者照片下方的信息,就像我添加的照片中一样。请让我知道我离此有多远?

1 个答案:

答案 0 :(得分:0)

基本上你想要的是一个带有id标签的div,它在某种事件上使用jquery切换,也许当有人点击其中一个图像时。对于第一部分,您需要类似以下代码:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>slideToggle demo</title>
  <style>
  p {
    width: 400px;
  }
  </style>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>

<button>Toggle</button>
<p>
  This is the paragraph to end all paragraphs.  You
  should feel <em>lucky</em> to have seen such a paragraph in
  your life.  Congratulations!
</p>

<script>
$( "button" ).click(function() {
  $( "p" ).slideToggle( "slow" );
});
</script>

</body>
</html>

这是http://api.jquery.com/slidetoggle/

您也可能希望从服务器动态加载信息。您可以使用jQuery来实现此功能:http://api.jquery.com/load/ 页面示例:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>load demo</title>
  <style>
  body {
    font-size: 12px;
    font-family: Arial;
  }
  </style>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>

<b>Projects:</b>
<ol id="new-projects"></ol>

<script>
$( "#new-projects" ).load( "/resources/load.html #projects li" );
</script>

</body>
</html>

但是有关用户的信息存储在哪里?你想写一些服务器吗?代码的AJAX部分允许您单击其中一个用户,然后为它们动态加载代码。

您需要告诉每张图片在点击时做出反应。这可以使用jQuery的.each()函数来完成,您可以在其中迭代每个li元素(图片)。

相关问题