html - 为什么我的 box div 位于本应位于其上方的两个元素后面?

标签 html css layout

我是一名网页设计新手,正在尝试解决我的 css 和/或 html 的问题。我的页面有两个 grid50 div,它们应该位于彩色框 div 之上。但是,该框位于其他部分的后面(尽管框内容被下推)。

我的 html:

<div>
<div class="grid-50 tablet-grid-50 mobile-grid-100 first-column">
   <?php $description = get_field('country_description', $term); 
    echo "<p>" . $description . "</p>";
     ?>
 </div>
 <div class="grid-50 tablet-grid-50 mobile-grid-100 second-column">

  <?php $description = get_field('country_description', $term);
  $map = get_field('country_map', $term);
  echo do_shortcode( ' '. $map .' ' ); 
    ?>
  </div>
</div>
<div class="infobox">
    <?php 
    $when = get_field('info_box_when', $term);
     $where = get_field('info_box_where', $term);
     $moment = get_field('info_box_moment', $term);
     $fact = get_field('info_box_fact', $term);
    $description = get_field('info_box', $term); 
    echo '<h6>' . 'When we visited:   ' . '</h6>' . '<p>' . $when . '</p>' . '<br>' .
        '<h6>' . 'Major stops:   ' . '</h6>' . '<p>' . $where . '</p>' . '<br>' .
        '<h6>' . 'Memorable moment:   ' . '</h6>' . '<p>' . $moment . '</p>' . '<br>' .
        '<h6>' . 'Did you know?   ' . '</h6>' . '<p>' . $fact . '</p>';
                    ?>
</div>

我的CSS:

.infobox {
    background-color: #bf593a;
    color: white;
    padding: 5%;
    border-radius: 10px ;
    margin-left:6%;
    margin-right: 6%;
    margin-top: 8%;
    margin-bottom: 10%;;
}

结果如下: https://theslowroad.org/category/destinations/asia/laos/

橙色框应该在文本和 map 下方。

最佳答案

看起来橙色 block 上方的文本和 map 是 float 的,这意味着您需要清除它。将 clear: both; 添加到橙色 (.infobox) 框的规则中。

关于html - 为什么我的 box div 位于本应位于其上方的两个元素后面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57342355/

相关文章:

javascript - iOS 自动播放视频 WebView

html - 如何在考虑周围空间的情况下将弹性盒的最后一个元素向右对齐?

css - 背景图像未加载

Android 自定义控件布局问题

uitableview - 第一个 tableview 部分的标题比其余部分大

html - 超出列表项出现在同一行

html - 将鼠标悬停在类上时更改 li 类的 CSS

html - 在 Cordova/Ionic 中放大特定的 div

html - FireFox 中的 `contenteditable = true` 高度问题

java - 如何使用 iText 为我的 (pdf-) 文本添加背景颜色以使用 Java 创建它