-3

これについてネットを閲覧していたいくつかの基本的なcssに問題がありますが、例は見つかりましたが、どれも私の問題を説明していません:

ページテンプレート [HTML]:

    <div id="container" class="gallery-list"> <!-----gallery-list---->
    <div id="content" role="main">
        <h1 class="page-title"><?php the_title(); ?></h1>
        <div id="gallery-list-container" class="list-container">
                <?php wp_reset_query(); ?> 
                <?php
                // Set up the arguments for retrieving the pages
                $args = array(
                    'post_type' => 'page',
                    'numberposts' => -1,
                    'post_status' => null,
                // $post->ID gets the ID of the current page
                'post_parent' => $post->ID,
                    'order' => ASC,
                    'orderby' => title
                    );
                 $subpages = get_posts($args);
                  if ($subpages[0]) :?>
                        <div class="gallery-list-wrap">
                            <?php
                             // Just another WordPress Loop
                             foreach($subpages as $post) :
                                setup_postdata($post);
                            ?>
                                <div id="post-<?php the_ID(); ?>" class="list-entry-container">
                                    <?php 
                                        $count++;
                                        // Show the Post thumbnail
                                        if ( has_post_thumbnail() ) : ?>

                                                <div class="list-entry">
                                                    <a class="size-small" href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
                                                    <h2 class="list-entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'highart' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                                                </div><!-- .entry-content -->                   
                                            <?php
                                        // Show the High Art image
                                         else : ?>
                                            <div class="entry-content">
                                                <?php highart_entry_image_attachment('thumbnail') ?>
                                            </div><!-- .entry-content -->                       
                                        <?php endif; ?>

                                        <div class="entry-utility">
                                            <?php edit_post_link( __( 'Edit', 'highart' ), '<span class="edit-link">', '</span>' ); ?>
                                        </div><!-- .entry-utility -->
                                </div>
                        <?php endforeach; ?>
                    </div>
                 <?php endif; ?>
        </div>
    </div><!-- #content -->
</div><!-- #container -->

[CSS]

#main .gallery-list{margin:0;width:925px;overflow:hidden; display:block;}
#main .gallery-list #content{width:925px;}
.list-container{margin:0 auto; display:block; padding:11px 0 0; list-style:none; border-bottom: 1px solid lightgray;}
.gallery-list #gallery-list-container {margin-top:-22px;float:none; width:925px;}
.gallery-list li {display:inline;width:185px;height:241px;margin-right:25px;padding:22px 0 44px;border:1px solid lightgray;border-width:0 0 0; position:relative; overflow:hidden;}
.gallery-list #gallery-list-container li {min-height:252px; display:inline;clear:none;padding-bottom:25px;}
.gallery-list-wrap{display:inline; float:left; margin:0 auto;}
.list-entry-container {display:inline; float:left;}
.gallery-list .list-entry{display:inline;width:165px;font-size: 9px; font-weight:400; line-height:11px; text-transform:uppercase; padding:5px 0 6px;}
.gallery-list-line-wrap{margin: 0 auto; display:block;}

div: gallery-list-wrap がコンテナを中心にしていないのはなぜですか? コンテナの左側に配置されたままです。

この場合、ブラウザがこれをどのように処理するのかよくわかりません。

おそらく初心者の質問ですが、私はそれを理解できないようです

EDIT1: 以下の回答によると、これは問題のあるアプローチになる可能性があるため、いくつかの裏話があります:ページのサムネイルとタイトルを含むサブページのdivを含むdivがあります。これまでのところ、問題はどれくらいあるのかわからないので、行ごとに1、2、3、または4があるかどうかわかりません。行ごとに最大4つ、各行をコンテナの中央に配置したいと思います

これは実行可能ですか?

手伝ってくれてありがとう。

4

2 に答える 2

1

消去:

display: inline;
float: left;
于 2012-08-15T10:42:06.403 に答える
1

削除する必要があります

display:inline;
float:left;

gallery-list-wrap に幅を追加します。

現時点では、margin-left と margin-right を auto に設定するのが正しい方法ですが、適切に機能させるには、幅も定義する必要があります。

したがって、そこに 2 つの div がある場合は、それらを組み合わせた幅を計算し、それを gallery-list-wrap に適用します。

これが役立つことを願っています。

于 2012-08-15T10:45:56.580 に答える