Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS Float属性不会将图像元素彼此相邻放置,有人看到代码有什么问题吗?_Css_Image_Html_Css Float_Stylesheet - Fatal编程技术网

CSS Float属性不会将图像元素彼此相邻放置,有人看到代码有什么问题吗?

CSS Float属性不会将图像元素彼此相邻放置,有人看到代码有什么问题吗?,css,image,html,css-float,stylesheet,Css,Image,Html,Css Float,Stylesheet,这是一个由论文驱动的Wordpress网站。我想做的是让一个特色帖子区域填满我放在特色/特色2类别中的任何帖子 这是PHP function custom_featured_box() { if(is_home()) { ?> <div id="featuredbox" class="clearfix"> <?php $my_query = new WP_Query('category_name=featured&showposts=1')

这是一个由论文驱动的Wordpress网站。我想做的是让一个特色帖子区域填满我放在特色/特色2类别中的任何帖子

这是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
} }
我不明白CSS为什么不让featuredbox次要帖子彼此相邻

任何帮助都将不胜感激


另外,这里有一个截图,显示了当前代码的样子,希望它能帮助人们理解我的意思

如果我理解正确,那么您希望ID为featuredbox secondary的div中的每个具有class secondary项的div彼此相邻浮动吗?如果是这样,您需要将float声明应用于类次要项。

您可以通过粘贴呈现的代码来帮助我们。是的,问题出在客户端-与PHP无关。因此CSS中的某些内容必须更改?同意@Kyle。您是否尝试增加容纳featurebox次要对象的容器的宽度,只是为了验证宽度是否不合适?我只是尝试更改featurebox次要对象的宽度和高度,以确保所有内容都正确匹配,并且没有任何效果。我有float:left;正在申请。第二项。是的,很抱歉。在我点击send几秒钟后就注意到了。只是一个简单的问题:其余的ID和类定义工作正常吗?没问题,这正是我的问题所在。我不明白为什么,如果我使用float,它不会将我的第二项放在彼此旁边。是的,它们工作正常,除了帖子的缩略图没有显示在我发布的图片的链接中之外,一切似乎都正常。PHP不是我的强项,但以divfeaturedbox secondary开头的整个块不是都在while循环中吗?
.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);}