2016-09-24 1 views
0

Ich möchte populäre-Auszug Rand-unten sein: 20px jedoch wird es nicht funktionieren. Ich habe versucht, sowohl Rand-Boden und Polster-Boden, aber keiner von ihnen funktioniert.Ich kann nicht Rand-Boden wird nicht funktionieren

Hier ist mein Code

a.popular-excerpt { 
 
    text-decoration: none; 
 
    color: #000000; 
 
    margin-bottom: 20px; 
 
}
<div id="slider"> 
 
<?php 
 
$carousel_cat = get_theme_mod('carousel_setting','1'); 
 
$carousel_count = get_theme_mod('count_setting','4'); 
 
$month = date('m'); 
 
$year = date('Y'); 
 
$new_query = new WP_Query(array('posts_per_page' => $carousel_count, 'meta_key' => 'wpb_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC','monthnum'=>$month,'year'=>$year)); 
 
?> 
 
<?php if ($new_query->have_posts()) : ?> 
 
<?php while ($new_query->have_posts()) : $new_query->the_post(); ?> 
 
<div class="item"> 
 
    <?php the_post_thumbnail('popular-posts'); ?> 
 
    <h2><a class="popular-category" 
 
     <?php 
 
     $categories = get_the_category(); 
 
     $separator = ", "; 
 
     $output = ''; 
 
     
 
     if ($categories) { 
 
      foreach ($categories as $category) { 
 
       $output .= '<a href="' . get_category_link($category->term_id) . '">' . $category->cat_name . '</a>' . $separator; 
 
      } 
 
      echo trim($output, $separator); 
 
     } 
 
     
 
     ?></a></h2> 
 
<p> 
 
    <a class="popular-excerpt" href="<?php the_permalink(); ?>"><?php echo get_the_excerpt(); ?></a> 
 
       </p> 
 
</div> 
 
<?php endwhile; wp_reset_postdata(); ?> 
 
<?php else : ?> 
 
<p><?php _e('Sorry, No Popular Posts Found '); ?></p> 
 
<?php endif; ?> 
 
</div>

+0

Vielleicht Magin Kollabieren ist der Täter: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing –

Antwort

1

Ihr <a> Element ist ein Inline-Element und oberen und unteren Ränder wirken sich nicht auf Inline-Elemente. Sie sollten display auf block oder inline-block einstellen.

a.popular-excerpt { 
    text-decoration: none; 
    color: #000000; 
    margin-bottom: 20px; 
    display:block; 
} 
+0

Es funktionierte, danke! – user6738171