简体   繁体   中英

How to make Instagram.js feed responsive in Bootstrap?

I'm making my first WordPress template based on Bootstrap3 . Now I'm trying to add a Instagram feed using instafeed.js . My problem is with making the Instagram feed responsive with the advantages of Bootstrap. Any ideas how I can change my code to fit Bootstrap3? I have tried adding the Bootstrap tags, but it either shows all images on one row, or one image on each row (without 100% width).

HTML (and JS)

<div class="container">

<div class="row">
<div id="instafeed">
</div>
</div>

</div>


<script type="text/javascript">

                    var feed = new Instafeed({
                        get: 'tagged',
                        tagName: 'HASHTAG',
                      clientId: 'MY_CLIENT_ID',
                      limit: 6,
                      template: '<div class="col-md-2"><a href="{{link}}" target="_blank"><img src="{{image}}" class="img-responsive" /><div class="likes">&hearts; {{likes}}</div></a></div>'
                    });
feed.run();

                </script>

CSS:

#instafeed a {
  padding:5px 5px 1px 5px;
  margin:10px;
  border:1px solid #e1e1e1;
  display:inline-block;
  border-radius: 4px;
  position:relative;
}

#instafeed .likes {
  background:rgba(176,76,76,0.8);
  font-family:sans-serif;
  font-size:1em;
  position:absolute;
  color:#ffffff;
  right:5px;
  top:5px;
  left:5px;
  opacity:0;
  text-align:center;
  line-height:150px;
  text-shadow:0 1px rgba(0,0,0,0.5);
  -webkit-font-smoothing:antialiased;
  -webkit-transition: opacity 100ms ease;
    -moz-transition: opacity 100ms ease;
    -o-transition: opacity 100ms ease;
    -ms-transition: opacity 100ms ease;
    transition: opacity 100ms ease;
}

#instafeed a:hover .likes {
  opacity:1;
}

In your template you can use responsive classes like this:

<div class="col-xs-12 col-sm-6 col-md-4 col-lg-2">

XS Screen (1 image in a row).

SM Screen (2 images in a row).

MD Screen (3 images in a row).

LG Screen (6 images in a row).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM