css - 为什么标题隐藏在前一个 div 元素下面?

标签 css wordpress

我正在尝试为页面设置样式 http://techno-french.com/french-news-room对于我的生活,我无法弄清楚为什么 H1 标题,

通过 Mots de L’actu 免费在线学习法语

部分被其上方右侧 float 的 div 遮挡。我试过将 2em 的底部边距放在上面的 Div 上,然后尝试将顶部边距放在包含标题的 Div 上。它在 Dreamweaver 中运行良好在WordPress之外,所以我怀疑 CSS 是正确的,但在 WordPress 内部,标题在其上方的 Div 下方滑动。我不是专家,但这似乎编码正确:

代码如下:

<div style="float: left; width:360px; height:467px;">
   <h2 style="text-align: center;">Top Stories: Le Progres</h2>
   [WordPress shortcode for an advanced iFrame]
</div>
<div style="float: right; width:517px; height:560px; margin-bottom: 2em;">
   <h2>Funny Helps Learning</h2>
   [WordPress shortcode for an advanced iFrame}
</div>
<div style="float: left; clear: both;">
   <h1 style="text-align: center; color: #0b00dd;">Learn French Online 
      Free with Mots de  L'actu
   </h1>
   TEXT
</div>

最佳答案

将左右浮动的 div 包裹到另一个 div 中,并向其添加 clearfix。它应该可以正常工作。

<div id="wrapper" class="clearfix">
   <div style="float: left; width:360px; height:467px;">

   <h2 style="text-align: center;">Top Stories: Le Progres</h2>

   [Wordpress shortcode for an advanced iFrame]

   </div>

   <div style="float: right; width:517px; height:560px; margin-bottom: 2em;">

   <h2>Funny Helps Learning</h2>

   [Wordpress shortcode for an advanced iFrame}

   </div>
</div>

<div style="float: left; clear: both;">

<h1 style="text-align: center; color: #0b00dd;">Learn French Online 
Free with Mots de  L'actu</h1>

TEXT

</div>

CSS:

.clearfix:after {
   content: " "; /* Older browser do not support empty content */
   visibility: hidden;
   display: block;
   height: 0;
   clear: both;
}

关于css - 为什么标题隐藏在前一个 div 元素下面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22275103/

相关文章:

c# - ColorTranslator.FromHtml() 到底支持什么,为什么会偏离 CSS 颜色解释规则?

javascript - 如何在不使用 Flash 的情况下实现图书预览(2 页展开)?

html - Wordpress 帖子网格图像在分辨率高于 1280 时留下灰色空间

javascript - TinyMCE 替换父节点

php - 点击 "Place Order"后转换货币

WordPress 自动草稿禁用

php - 哪种方法更适合搜索引擎优化 (SEO)?

html - 在向上滚动动画中垂直居中 <p>

mysql - 从同一列中选择特定值并显示在不同的列中

javascript - 如何选择带有列表项的偶数行