我的div不会向左或向右浮动?

时间:2012-10-01 09:46:05

标签: css css-float

我收到错误,因为我的div根本不会浮动

这是我的css

#content {
width: 1070px;
}

.date{
float:left;
width:80px;
margin: 50px 8px 0px -60px;
padding: 0px 0px 0px 0px;
}

.month {
color:#fff;
font-size:15px;
font-family:eurofurence;
text-transform:uppercase;  
}

.year {
color:#fff;
padding:0 0 7px 0;
font-size:30px;
font-family:eurofurence;
text-transform:uppercase;  
}
 .commentbubble{
  background: url('http://bleedartmedia.com/mock/wp-content/themes/KellyRowland/images/commentb.png') no-repeat;
  width:40px;
  height:49px;
  padding:4px 0 0 14px;
  }
    .entry {
    float:right;
margin: 0px 8px 0px 0px;
padding: 20px 0px 0px 0px;
border-bottom: 0px solid #cccccc;
    font-family:eurofurence;
    font-size:17px;
    width:610px;
    background:#fff;
}

这是我的设置

            <div id="content">
 <?php while ( have_posts() ) : the_post() ?>   

 <div class="date">
 <div class='month'><?php the_date('M');?></div>
 <div class='year'><?php the_time('d');?></div>
 <div class="commentbubble">
 <?php comments_popup_link( __( '0', 'wpbx' ), __( '1', 'wpbx' ), __( '%', 'wpbx' ) ) ?>
 </div>
 Comments
 </div>

    <div class="entry">
        <div class="entry-top">
            <h2 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf( __('Permalink to %s', 'wpbx'), the_title_attribute('echo=0') ) ?>" rel="bookmark"><?php the_title() ?></a></h2>
    </div>
            <div class="entry-content clearfix">

        <div class="entry-content">
                <div id="text"><?php the_content() ?></div>
                </div>

            </div>

            <div class="entry-meta">
                <span class="entry-meta-sep">|</span>
                <span class="entry-more"><a href="<?php the_permalink() ?>" title="<?php printf(__('Continue reading %s'), wp_specialchars(get_the_title(), 1)) ?>"><?php _e( 'Read More &raquo;', 'wpbx' ) ?></a></span>
            </div>
    </div><!-- .post -->
 <?php endwhile; ?>

        <div class="navigation clearfix">
            <div class="nav-previous"><?php next_posts_link(__( 'Previous <span class="meta-nav">Articles</span>', 'wpbx' )) ?></div>
            <div class="nav-next"><?php previous_posts_link(__( 'Next <span class="meta-nav">Articles</span>', 'wpbx' )) ?></div>
        </div>

    </div><!-- #content -->

问题是我希望“date”div浮动到“entry”div的左边但是所有“date”div正在做的是坐在条目div的顶部为什么会这样?

2 个答案:

答案 0 :(得分:4)

您尚未关闭.date DIV

<div class="date">Date</div>

将来我会用

替换CSS
.right{float:right}
.left{float:left}

然后你可以说<div class="date right"> </div>

清洁CSS:

#content{width:1070px}
.right{float:right}
.left{float:left}
.date{width:80px;margin:50px 8px 0px -60px;padding:0px; }
.month{color:#fff;font-size:15px;font-family:eurofurence;text-transform:uppercase}
.year{color:#fff;padding:0 0 7px 0;font-size:30px;font-family:eurofurence;text-transform:uppercase}
.commentbubble{background:url('http://bleedartmedia.com/mock/wp-content/themes/KellyRowland/images/commentb.png') no-repeat;width:40px;height:49px;padding:4px 0 0 14px}
.entry{margin:0px 8px 0px 0px;padding:20px 0px 0px 0px;border-bottom:0px solid #ccc;font-family:eurofurence;font-size:17px;width:610px;background:#fff}

另外

padding:0px; 

相同
padding:0px 0px 0px 0px;

color:#ffffff; 
color:#cccccc;

相同
color:#fff; 
color:#ccc;

如果您无法查看日期DIV,请移除已设置的否定margin -60px

答案 1 :(得分:0)

尝试

<强> HTML

    <div id="content">

      <div class="date">           

      </div>
      <div class="entry">

      </div>

    </div>

<强> CSS

#content
{
 float:left;
 width:1070px;
}

.date{
float:left;
width:80px;
}

.entry
 {
 float:right;
 }