只有在窗口调整大小后,砌体才能正常工作

时间:2015-05-05 01:13:13

标签: php html wordpress zurb-foundation masonry

网站:www.zrrdigitalmedia.com

当项目部分中的图像加载时,砌体将其重叠到下一个中​​。当你调整窗口大小并返回它看起来很好 - 就像它在我的XAMPP网站上做的那样。

下面是用于项目部分的HTML代码,其中包含了Masonry部分(没有使用JS进行砌体处理)。我正在使用Wordpress& Zurb Foundation(基于一个名为FoundationPress的模板。)我也在使用Masonry和Foundation的块网格。

<div id="projects-section" class="row">
<h1 id="projects">PROJECTS</h1>
<div id="projects-divider"></div>
<div class="small-12 columns" role="main">
    <div id="container" class="js-masonry" data-masonry-options='{ "itemSelector": ".item" }'>
        <?php do_action( 'foundationpress_before_content' ); ?>
        <ul class="small-block-grid-1 medium-block-grid-2 large-block-grid-3">

        <?php
        $args = array('cat' => 'uncategorized',
                      'post_type' => 'post',
                      'post_status' => 'publish',
                      'posts_per_page' => -1,
                      'caller_gets_posts' => 1
                      );
        $category_posts = new WP_Query($args);

        if($category_posts->have_posts()) : 
            while($category_posts->have_posts()) : 
                $category_posts->the_post();
            ?>
            <li class="item">
                <div class="post-thumbnail"> 
                    <a href="<?php the_permalink();?>"><?php if(has_post_thumbnail()){the_post_thumbnail();} ?></a>
                </div>
                <h2><?php the_title() ?></h2>
                <div class='post-content'><?php the_content() ?></div>      
                <div class="post-divider"></div>
            </li>

            <?php
            endwhile;
            else: 
                ?>
            Oops, there are no posts.
            <?php
        endif;
        ?>
        </ul>
        <?php do_action( 'foundationpress_after_content' ); ?>
    </div>
</div>

我不确定为什么现在该网站的现场表现不同。任何帮助都会很棒。如果我需要发布更多代码,也请告诉我。谢谢!

1 个答案:

答案 0 :(得分:3)

一个非常常见的问题听起来像是你在描述的是Masonry设置你的元素但你的图像还没有加载。

Masonry文档建议使用#import "SDLBluetoothConnectViewController.h" #import "SDLStickReaderManager.h" #import "SDLStickReader.h" #import "SDLViewController.h" @interface SDLBluetoothConnectViewController () <UITableViewDataSource, UITableViewDelegate, SDLStickReaderManagerListener> @property (weak, nonatomic) IBOutlet UITableView *stickReaderListView; @property (strong, nonatomic) IBOutlet UILabel *stickReaderNameLabel; @property (strong, nonatomic) IBOutlet UILabel *stickReaderDescLabel; @end /* This class starts the process of scanning in the 'viewDidLoad' method by setting the SDLStickReaderManager 'singleton' to self. When the scan button is pressed the SDLStickReaderManager scan is called, and each stick reader found is returned via the listener call. This listener call is used to refresh the table view. When a user selects a stick reader from the list the StickReader view is started and passed the selected stick reader. */ @implementation SDLBluetoothConnectViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self.stickReaderListView setDelegate: self]; [self.stickReaderListView setDataSource: self]; [SDLStickReader manager].listener = self; [self.stickReaderListView reloadData]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)scanButtonPressed:(id)sender { [SDLStickReader.manager scan]; } - (IBAction)cancelButtonPressed:(id)sender { SDLStickReader.manager.listener = nil; [self dismissViewControllerAnimated:YES completion:nil]; } -(void)viewWillDisappear:(BOOL)animated { /* Every time the view disappears, you should stop the scanning process. */ [SDLStickReader.manager stopScan]; } ///////////////////////////////////////////////////////////////////////////////// /////// Table handling ////////////////////////////////////////////////////////// -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSArray *stickReaders = SDLStickReader.manager.discoveredStickReaders; SDLStickReader * stickReader = [stickReaders objectAtIndex: indexPath.row]; [SDLStickReader.manager stopScan]; [self performSegueWithIdentifier:@"deviceInfoSegue" sender:self]; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSArray *stickReaders = SDLStickReader.manager.discoveredStickReaders; return stickReaders.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString * simpleTableIdentifier = @"SimpleTableCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: simpleTableIdentifier]; if (nil == cell) { cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: simpleTableIdentifier]; } NSArray *stickReaders = SDLStickReader.manager.discoveredStickReaders; SDLStickReader * stickReader = [stickReaders objectAtIndex: indexPath.row]; NSString *desc = [stickReader name]; cell.textLabel.text = desc; return cell; } -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"deviceInfoSegue"]) { //some additional info here } } ////////////////////////////////////////////////////////////////////////////////// / /// SDLStickReaderManager callbacks /////////////////////////////////////////////// -(void)stickReader: (SDLStickReader *)stickReader addedToList: (NSArray *)discoveredStickReaders { //NSLog(@"View StickReaderAdded"); [self.stickReaderListView reloadData]; //[SDLStickReader.manager connect: stickReader]; } -(void)connectedStickReader: (SDLStickReader *)stickReader { //NSLog(@"View StickReader connected"); [self.stickReaderListView reloadData]; } -(void)disconnectedStickReader: (SDLStickReader *)stickReader { //NSLog(@"View StickReader disconnected"); [self.stickReaderListView reloadData]; }

http://masonry.desandro.com/appendix.html

imagesLoaded()