【问题标题】:hr should be longer (width) than divhr 应该比 div 长(宽)
【发布时间】:2015-03-26 01:32:14
【问题描述】:

我有一个网页,当网页显示在平板电脑上时,我使用<hr> 标签来分隔内容。它看起来像这样:

在红色矩形处,这条线应该继续。但是,事实并非如此。为了让<hr> 一直持续到页面边框,我必须在 html/css 中进行哪些更改?

页面在这里:http://crossroads-festival.org/test2015/en/film/almaen 请注意将浏览器宽度减小到至少 811px 以显示水平线。

感谢您的帮助!

更新: <hr> 的 CSS 是

hr {
  height: 0;
  border: none;
  border-bottom: 1px solid #c1c1c1;
  margin-bottom: 1.5em;
  background: none;
}

divider-mobile 类的 css 是:

.divider-mobile {
  margin-top: 3.125em;
  margin-bottom: 3.125em;
  overflow: visible;
  border: none;
  color: #888888;
  background-color: #888888;
  height: 1px;
  width: 150%;
  margin-left: -25%;
}

在 html 中我这样使用它:

<hr class="divider-mobile">

【问题讨论】:

标签: html css width


【解决方案1】:

在你的 CSS 中你有:

#filmcontent {
  overflow-x: hidden;
}

这可以防止&lt;hr&gt; 上的负边距到达页面边缘。

您还需要删除&lt;hr&gt; 上的width: 150%;margin-left: 25%,而是这样做...

margin-left: -20px;
margin-right: -20px;

(其中 20px 等于 #content .entry-content 上的填充)

这会得到你想要的效果!

【讨论】:

  • 嗯,差不多了。我现在按照你说的设置margin-leftmargin-right。我还在&lt;hr&gt; 上删除了width。我还删除了overflow-x: hidden。但是,&lt;hr&gt; 根本不会显示。我必须再次添加width: 100% 才能让它再次出现。当然,那么它太短了..而且它似乎忽略了边距(请参阅&lt;hr&gt; 顶部的橙色区域:i.imgur.com/1MRmeeM.png)我很感激再试一次。谢谢!
  • 我玩了更多,现在它可以工作了。基本上按照你的建议。非常感谢您的帮助(与我原来的问题上令人讨厌的 cmets 形成对比!)
猜你喜欢
  • 2014-03-22
  • 2021-07-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-17
  • 1970-01-01
  • 1970-01-01
  • 2014-08-28
  • 2011-11-08
相关资源
最近更新 更多