开发者

CSS Float attribute won't place image elements next to each other, anyone see what's wrong with the code?

This is for a Wordpress site powered by Thesis. What I'm trying to do is have a featured posts area filled with whichever posts I put in the featured/featured2 categories.

This is the PHP

function custom_featured_box() {
    if(is_home()) {
?>
<div id="featuredbox" class="clearfix">
        <?php $my_query = new WP_Query('category_name=featured&showposts=1');
        while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID;
        ?>
            <div id="featuredbox-main" style="background: url(<?php the_post_thumbnail('featured') ?>) no-repeat;">
                <a href="<?php the_permalink() ?>"><?php the_title() ?></a>
            </div>
            <?php endwhile; ?>
        <?php $my_query = new WP_Query('category_name=featured2&showposts=3');
        while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; 
        ?>
            <div id="featuredbox-secondary">
                <div class="secondary-item" style="width: 205px; background: url(<?php the_post_thumbnail() ?>) no-repeat;">
                    <a href="<?php the_permalink() ?>"><?php the_title() ?></a>
                </div>
            </div>
        <?php endwhile; ?>
    </div>
<?php
} }

The "new WP_Query" function is just calling the category "featured" and "featured2" (<-- this is for the secondary featured posts) and taking the first post (for the "featured" category) and first 3 (for the "featured2" category) and placing them in the featured posts section. The only problem I'm having is that the #featured-secondary isn't putting the "featured2" posts next to each other. Also the thumbnail images aren't displaying but I haven't bothered trying to figure that out yet.

Here is the CSS:

.custom #feature_box { padding:0em; }

.custom #featuredbox { padding: 8px 0 10px 0;}
.custom #featuredbox-main {overflow: hidden; width: 650px; height: 225px; border: solid      
1px #ccc; margin: 0 0 10px 0; position: relative;}
.custom #featuredbox-main a:hover {text-decoration: underline;}
    .custom #featuredbox-main a {z-index: 1; position: absolute; top: 121px; min-   
height: 35px; left: 0; font-size: 20px; font-weight: bold; color: #fff; padding: 15px 
10px; width: 100%; background: url(http://location-of-the-background-here);}

.custom #featuredbox-secondary {height: 162px; overflow: hidden; width: 650px;}
    .custom .secondary-item {margin-right: 10px; position: relative; border: solid 1px 
#ccc; height: 160px; float: left; overflow: hidden;}
    .custom .secondary-item a:hover {text-decoration: underline;}
    .custom .secondary-item a {z-index: 1; position: absolute; top: 52px; left: 0; 
font-size: 12px; font-weight: bold; color: #fff; padding: 8px 10px; width: 185px;    
background: url(http://location-of-the-background-here);}

I don't see why the CSS isn't making the #featuredbox-secondary posts to be placed next开发者_高级运维 to each other.

Any help would be greatly appreciated.

P.S. here's a to screenshot of what it looks like with the current code, hopefully it helps people understand what I'm getting at. http://img43.imageshack.us/img43/3011/csshelp.jpg


If I understand you correctly, then you want every div with the class "secondary-item" which is inside the div with the ID "featuredbox-secondary" to float right next to each other? If so, you need to apply the float declaration to the class "secondary-item".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜