Css 我的设计有两列,右边在右边,但在左边的下面。为什么?
我的设计有两列。leftcolumn和。rightcolumn。在我的设计中,它们应该是相邻的,它们应该是左侧和右侧,但是.right列在右侧的.leftcolumn下面。为什么? CSS: 页面: 在foreach$tags as$tag:loop中,在leftcolumn中,您打开了一个循环,但没有关闭它,看起来您正在尝试在循环结束后关闭它,endforeach;?>所以我会把它移到$nextTagThumb=$nextTagThumb+1之后;在你的循环中 此外,您还有一个应位于顶部附近的:Css 我的设计有两列,右边在右边,但在左边的下面。为什么?,css,Css,我的设计有两列。leftcolumn和。rightcolumn。在我的设计中,它们应该是相邻的,它们应该是左侧和右侧,但是.right列在右侧的.leftcolumn下面。为什么? CSS: 页面: 在foreach$tags as$tag:loop中,在leftcolumn中,您打开了一个循环,但没有关闭它,看起来您正在尝试在循环结束后关闭它,endforeach;?>所以我会把它移到$nextTagThumb=$nextTagThumb+1之后;在你的循环中 此外,您还有一个应位于顶部附近的
此外,您的html中没有标记,所有其他内容都应该在标记中。您能否制作一个简化的代码示例来重现此问题?现在,您有太多的代码无法轻松浏览。或者页面的链接?通过一个最小、完整且可验证的示例,我可以注意到您的CSS还可以:。值得一提的是,您正在WordPress中工作。。。这意味着还有其他风格在发挥作用。一个缺少的结束div可能会破坏布局,尤其是浮动。好的,谢谢,就这样。我已经被困在这个位子上差不多一个小时了。是潜水艇放错地方了!多谢各位
.coursecontent {
width: 1200px;
}
.leftcolumn{
width: 860px;
float: left;
border-right-style: solid;
border-right-width: 2px;
border-right-color: #efefef;
}
.rightcolumn{
float: right;
width: 300px;
}
<!DOCTYPE html>
<html>
<?php
/**
* Template Name: Single event template
*/
get_header(); ?>
<div class="coursecontent">
<div class="leftcolumn">
<?php while ( have_posts() ) : the_post(); ?>
<h1> <?php the_title(); ?> </h1>
</br> <?php
echo '<div class="tagsremove">';
global $post;
$nextTagThumb='-1';
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag) :
if ($tags) {
$what_tag = $tags[($nextTagThumb+'1')]->term_id;
$args=array(
'tag__in' => array($what_tag),
'post__not_in' => array($post->ID),
'showposts'=>100,
'caller_get_posts'=>1
); ?>
<div class="tags_course_single">
<h5> Similar courses: </h5>
<?php $my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php echo get_permalink(); ?>"> <?php the_title(); ?></a>,
<?php endwhile;
}
wp_reset_query();
$nextTagThumb = ($nextTagThumb+1);
}
endforeach;
?> </div> <br />
<?php echo '</div>'; ?>
<div class="imageandtext">
<div class="mainimage">
<?php if ( has_post_thumbnail() ) { the_post_thumbnail();} ?>
</div>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
</div>
<div class="rightcolumn">
<div class="countersingle">
<h4> When this course starts: </h4>
<h6> (there maybe more than one possible start date) </h6>
<?php
$count = 0;
$your_repeater = get_field('add_date');
if($your_repeater){
while( have_rows('add_date') ): the_row();
$count++;
$my_field = get_sub_field('course_date');
if ($count == 1) {
$todays_date = date("Y-m-d");
$today = strtotime($todays_date);
$expiration_date = strtotime($my_field);
if ($expiration_date > $today) {
$date12 = new DateTime($my_field);
$date13 = new DateTime($todays_date);
$diff=date_diff($date12,$date13);
echo '1. ' . $my_field ;
echo '<div class="reddays"> in '. $diff->format("%R%a days.") .'<a href="'.get_page_link('10') .'"> Contact us now</a></div>';
} else {
echo '' ;
} }
if ($count == 2) {
$todays_date = date("Y-m-d");
$today = strtotime($todays_date);
$expiration_date = strtotime($my_field);
if ($expiration_date > $today) {
$date12 = new DateTime($my_field);
$date13 = new DateTime($todays_date);
$diff=date_diff($date12,$date13);
echo '2. ' .$my_field ;
echo '<div class="reddays"> in '. $diff->format("%R%a days.") .'<a href="'.get_page_link('10') .'"> Contact us now</a></div>';
} else {
echo '' ;
}}
if ($count == 3) {
$todays_date = date("Y-m-d");
$today = strtotime($todays_date);
$expiration_date = strtotime($my_field);
if ($expiration_date > $today) {
$date12 = new DateTime($my_field);
$date13 = new DateTime($todays_date);
$diff=date_diff($date12,$date13);
echo '3. ' .$my_field ;
echo '<div class="reddays"> in '. $diff->format("%R%a days.") .'<a href="'.get_page_link('10') .'"> Contact us now</a></div>';
} else {
echo '' ;
} }
if ($count == 4) {
}
if ($count == 5) {
}
echo '</ul>';
endwhile;
}?>
</div>
<div class="mathsandenglish">
<h4> Improve your maths and English at the same time </h4>
<?php $key_1_value = get_post_meta( get_the_ID(), 'twitter_embed', true );
if( ! empty( $key_1_value ) ) {
echo $key_1_value; } ?>
</div>
</div>
</div>
<?php get_footer(); ?>
</html>