2012-08-15 239 views
-4

的div容器我有一些基本的CSS的東西,我browseing淨值爲這一點,但發現的例子,但這些方法都解釋了我的問題一個問題:不居中

頁面模板[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:像冊列表外包裝不居中在容器上? 它僅僅停留的對準集裝箱的左側。

在這種情況下,我真的不明白瀏覽器如何處理這個。

可能是一個新手的問​​題,但我似乎無法弄清楚

EDIT1: 按照下面的答案,這可能是對這個有問題的方法,使一些背景故事: 我有一個div即包含帶有縮略圖和頁面標題的div頁面。到目前爲止好這個問題是我不知道如何曼尼有,所以我不知道如果我有1,2,3或4每行我想有每行最多4和中心到容器每一行

這是可行的eaven?

感謝您的幫助。

+3

您最好不要鏈接到事物,而是發佈您的實際問題 - 或者演示其行爲的表示,以便人們可以在將來找到您的帖子時參考和理解。 – BugFinder 2012-08-15 10:37:07

+0

解決問題的一個部分就是理解它。這是一個主觀的過程中,我們盡力幫助這裏也一樣,但實際上你需要問一個具體問題是使用別人的了。不僅爲你自己。這不是一個「如何讓我成爲我的網站」論壇,而是一個編程問答網站。 – hakre 2012-08-15 10:38:43

+0

添加了HTML和CSS – Jester 2012-08-15 10:41:30

回答

1

您需要刪除

display:inline; 
float:left; 

和寬度添加到庫列表纏繞。

目前,您將margin-left和margin-right設置爲auto,這是正確的操作,但爲了正常工作,您還需要定義寬度。

所以,如果你有兩個div在那裏,解決他們的組合寬度,並將其應用到畫廊列表包裝。

我希望這會有所幫助。

+0

感謝您的幫助部分地查看:編輯1 – Jester 2012-08-15 10:51:32

+0

至於編輯1:添加到您的畫廊列表包裝寬度:925px;文本對齊:中心;然後使list-entry-container顯示:inline-block;並刪除其浮動左 – 2012-08-15 10:52:40

+0

你是一個天才要比先生感謝您和+1 OFC – Jester 2012-08-15 10:59:53

1

刪除:

display: inline; 
float: left; 
+0

感謝您的幫助部分查看:編輯1 – Jester 2012-08-15 10:50:24