页面加载时的照片对齐方式应为网格

时间:2016-06-24 12:53:23

标签: javascript jquery html css

我正在处理一个页面,其中包含需要以3列开头的网格显示的图片。但每次页面加载时,图片都会加载为一列直接向下到页面的左侧。

只有一次拉伸浏览器才会重新调整照片。

一旦页面加载,我希望它已经在3列的网格中。

任何想法?



 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    
    
    

    <script type="{{site.baseurl}}/js/scrollspy.js"></script>
    <script src="swipebox/lib/jquery-1.9.0.js"></script>
    <script type="text/javascript" src="js/modernizr.custom.js"></script>
    <script src="swipebox/lib/ios-orientationchange-fix.js"></script>
    <script src="swipebox/lib/jquery-2.1.0.min.js"></script>
    <script type="text/javascript" src="js/jquery-1.9.0.js"></script>

    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>

    <script>
                 //When the DOM document is loaded in the browser

            $(document).ready(function () {
        
    
    
    
      <!-- jQuery -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script type="text/javascript">
    $("#menu-close").click(function(e) {
        e.preventDefault();
        $("#sidebar-wrapper").toggleClass("active");
		$("#menu-toggle").show("active");
		$("#menu-close").hide("active"); 
		

    });

    // Opens the sidebar menu
    $("#menu-toggle").click(function(e) {
        e.preventDefault();
        $("#sidebar-wrapper").toggleClass("active");
		$("#menu-close").show("active"); 
		$("#menu-toggle").hide("active"); 
		
		
		
    });


     // Closes the sidebar menu
    $("#menu-close2").click(function(e) {
        e.preventDefault();
        $("#sidebar-wrapper2").toggleClass("active")//slideUp(50);
    });

    // Opens the sidebar menu
    $("#menu-toggle2").click(function(e) {
        e.preventDefault();
        $("#sidebar-wrapper2").toggleClass("active")//slideDown(50);
    });

    /* Basic Gallery */
          
          
   
      
</script>
<script type="text/javascript">
    // Scrolls to the selected menu item on the page
    $(function() {
        $('a[href*=#]:not([href=#])').click(function() {
            if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') || location.hostname == this.hostname) {

                var target = $(this.hash);
                target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
                if (target.length) {
                    $('html,body').animate({
                        scrollTop: target.offset().top
                    }, 1000);
                    return false;
                }
            }
        });
    });
    </script>

 

                    <script src="bower_components/metisMenu/dist/metisMenu.min.js"></script>
    <!-- Plugin JavaScript -->
    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>

      <!-- jQuery -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

    <!-- Plugin JavaScript -->
    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
    <script src="js/classie.js"></script>
    <script src="js/cbpAnimatedHeader.js"></script>

    <!-- Contact Form JavaScript -->
    <script src="js/jqBootstrapValidation.js"></script>
    <script src="js/contact_me.js"></script>
    

    <!-- Custom Theme JavaScript -->
    <script src="js/agency.js"></script>

      
<script src="lib/ios-orientationchange-fix.js"></script>
  <script src="lib/jquery-2.1.0.min.js"></script>
  <script src="js/jquery.swipebox.js"></script>

<!--  <script type="text/javascript" src="js/SmoothScroll.js"></script>
 -->    <script type="text/javascript" src="js/jquery.isotope.js"></script>
	
  <script type="text/javascript">
jQuery(function($) {
  $(".swipebox").swipebox();
});
</script>




	<!-- 
<script type="text/javascript">
    $( document ).ready(function() {

            /* Basic Gallery */
            $( '.swipebox' ).swipebox();
            
            /* Video */
            $( '.swipebox-video' ).swipebox();

            /* Dynamic Gallery */
            $( '#gallery' ).click( function( e ) {
                e.preventDefault();
                $.swipebox( [
                    { href : 'http://swipebox.csag.co/mages/image-1.jpg', title : 'My Caption' },
                    { href : 'http://swipebox.csag.co/images/image-2.jpg', title : 'My Second Caption' }
                ] );
            } );

      });
    </script>
     -->
<!-- <script type="text/javascript" src="js/main.js"></script> -->
<script src="js/owl.carousel.js"></script>
<!-- <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js'></script>
 --><script src='http://npmcdn.com/isotope-layout@3/dist/isotope.pkgd.js'></script>

<script src="js/index.js"></script>
&#13;
  <link href="font-awesome/fonts/plugin.css" rel="stylesheet" type="text/css">
    <link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="css/plugin.css" rel="stylesheet" type="text/css">
<link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap.css" rel="stylesheet" type="text/css">

    <!-- Custom CSS -->

    <link rel="stylesheet" href="demo/normalize.css">
    <link rel="stylesheet" href="demo/bagpakk.min.css">
    <link rel="stylesheet" href="src/css/swipebox.css">
    <link rel="stylesheet" href="css/stylish-portfolio.css">
    <link rel="stylesheet" href="css/style.css">
    
    <link rel="stylesheet" href="swipebox/src/css/swipebox.css">
    <link rel="stylesheet" href="swipebox/src/css/swipebox.min.css">
    <link rel="stylesheet" href="swipebox/demo/normalize.css">
    <link rel="stylesheet" href="swipebox/demo/bagpakk.min.css">
    <link rel="stylesheet" href="swipebox/demo/style.css">
    
    <link rel="stylesheet"  href="css/owl.carousel.css" media="screen">
    <link rel="stylesheet"  href="css/owl.theme.css"media="screen">
    

    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
&#13;
    <section id="portfolio" class="portfolio" style="display: none;" >
             <div class="container">
   
                <div class="row">
                <div class="col-lg-12 col-md-12 text-center">
                    <h2><font style="text-transform: uppercase;"face="Helvetica" >Portfolio</font></h2>
                    <hr class="large">
                </div>
                </div>
                 
<div class="button-group filters-button-group">
  <button class="button is-checked" data-filter="*">show all</button>
  <button class="button" data-filter=".ling">Lingeria</button>
  <button class="button" data-filter=".men">Men</button>
  <button class="button" data-filter=".women">Women</button>
</div>
                 
<div class="grid">
  <div class="element-item men " data-category="men">
  
  <img class="img-portfolio img-responsive" src="img/1.jpg" style="width: 300px; height: 300px;">
  
  </div>
  
  <div class="element-item ling" data-category="ling">
   <img class="img-portfolio img-responsive" src="img/2.jpg" style="width: 300px; height: 300px;">
  
  </div>
  
   <div class="element-item men" data-category="men">
   <img class="img-portfolio img-responsive" src="img/3.jpg" style="width: 300px; height: 300px;">
  
  </div>
  
  
  <div class="element-item women" data-category="women">
   <img class="img-portfolio img-responsive" src="img/4.jpg" style="width: 300px; height: 300px;">
  
  </div>
  
  <div class="element-item ling " data-category="ling">
   <img class="img-portfolio img-responsive" src="img/5.jpg" style="width: 300px; height: 300px;">
  
  </div>
 </div>
        </div>
    </section>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

将此添加到Document.ready()

的末尾
$( window ).resize()

我认为应该可行,它会调用浏览器上的resize事件,该事件应触发更改。

Ps:我建议删除你在页面上加载的所有不同版本的Jquery。