【问题标题】:HR displayed different in FirefoxHR 在 Firefox 中显示不同
【发布时间】:2019-11-02 18:03:34
【问题描述】:

正如标题所解释的,我在显示 <hr> 行时遇到了一点问题。

在IE 7, 8, 9, Google Chrome, Opera Safari,都一样,没问题,只是不支持阴影等CSS3效果。

我正在尝试 2 做的是,通过添加该行来分隔一些新闻文章,但在 Firefox 中,该行不在容器中,就像有位置:absolute;padding: 500px;

这是我的 html 标记:

    <div class="container">

            <div class="main-content-container">
            <div class="article-container">
<div class="article-header">
<p class="article-count">0</p><p class="article-categories">1,2, 3, 4, 5</p>
<h1 class="article-title"><a href='#'>Lorem Ipsum is simply dummy</a></h1>
<p class="article-auth-date">2013 Apr 06</p>
</div> <!-- end of article-header -->

<img alt="bla bla bla" src="http:/localhost/uploads/test.png" style="border: none;">

<div class="article-post">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry&#39;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p></div><!-- end of article-post-->
</div>

<hr class="fancy-hr">           
</div><!-- end of article-container -->
</div><!-- end of main-content-container -->

 <aside></aside><!-- end of aside -->

 </div><!-- end of container -->

这是 CSS :

.main-content-container {
            float:left;
            margin: 5px 0 0;
            padding: 0;
            width: 660px;
            height: 800px;
            background-color: white;

            -moz-box-shadow:inset 0px 0px 20px 4px rgba(173, 173, 173, 0.5);
            -webkit-box-shadow:inset 0px 0px 20px 4px rgba(173, 173, 173, 0.5);
            box-shadow:inset 0px 0px 20px 4px rgba(173, 173, 173, 0.5);
            border: 1px solid #818080;

.article-container {
    float: left;
    margin: 20px;
    padding: 0;
    width: 615px;
}

    .article-header {
        float: left;
        margin: 0;
        padding: 5px 0 0 ;
        width: 100%;
        height: 50px;
        margin-bottom: 20px;
    }

.article-post {
        border-top:1px solid #D3D3D3;
        text-align:justify; 
        padding:3px; 
        margin-top:3px; 
        margin-bottom:5px;
        font-size: 14px;
        font-family: 'Lato', sans-serif;
        color: #000;
    }

    hr.fancy-hr {
        width: 100%;
        border: 0;
        height: 1px;
        background: #c5c3c3;
        -webkit-box-shadow: 2px 0px 20px rgba(50, 50, 50, 0.75);
        -moz-box-shadow:    2px 0px 20px rgba(50, 50, 50, 0.75);
        box-shadow:         2px 0px 20px rgba(50, 50, 50, 0.75);
    }

还有 2 张来自 Google Chrome 和 Firefox 的屏幕截图:

http://i1217.photobucket.com/albums/dd399/MarianStroiu/googlechrome.png谷歌浏览器

http://i1217.photobucket.com/albums/dd399/MarianStroiu/ff.png火狐

【问题讨论】:

    标签: html css firefox


    【解决方案1】:

    hr 的支持很少,在浏览器中也没有得到很好的处理。根据我的经验,它并没有被大量使用。下面的代码是您想要的常见做法,根据您的感受自定义它 -

    div.line {
    border-bottom:thin solid #fff;
    }
    
    <div class="container">
    
            <div class="main-content-container">
            <div class="article-container">
    <div class="article-header">
    <p class="article-count">0</p><p class="article-categories">1,2, 3, 4, 5</p>
    <h1 class="article-title"><a href='#'>Lorem Ipsum is simply dummy</a></h1>
    <p class="article-auth-date">2013 Apr 06</p>
    </div> <!-- end of article-header -->
    
    <img alt="bla bla bla" src="http:/localhost/uploads/test.png" style="border: none;">
    
    <div class="article-post">
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry&#39;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p></div><!-- end of article-post-->
    </div>
    
    <!--<hr class="fancy-hr">--> do not use
    <div class="line"></div>
    
    </div><!-- end of article-container -->
    </div><!-- end of main-content-container -->
    

    【讨论】:

    • 另一种选择是添加一个 reset.css 以确保所有浏览器 css 默认值都已关闭。
    【解决方案2】:

    这与前景色有关,Kevin Lynch 的修复在浅灰色 (#d1d1d1) 正文背景的页面上对我不起作用。 将 HR 颜色更改为白色确实有效,现在它显示为蚀刻。

    hr {color: #ffffff;}
    

    在实践中,HR 只需要比背景更亮的任何阴影,所以白色总是有效的。

    【讨论】:

      【解决方案3】:

      我确定这对您来说并不理想,但不必担心所有样式,为什么不直接将其设为 IMAGE 而不是 HR?它会更容易维护,并且可以简单地包含为宽图像并简化您的所有 CSS。

      否则,您是否尝试过降低 HR 的宽度?这听起来很愚蠢,但我之前遇到过宽度使 HR 元素从其 div 中弹出的情况。

      【讨论】:

      • 我试过了,但还是一样。我想我需要 2 为 hr 行定义一些 Reset CSS。不过还是谢谢
      • 不!我忘了提到添加“clear:both;”如果您将它插入到它不断弹出的 DIV 中可能会有所帮助。
      猜你喜欢
      • 2014-03-20
      • 2014-12-08
      • 1970-01-01
      • 2015-11-03
      • 1970-01-01
      • 2017-11-16
      • 1970-01-01
      • 2017-01-08
      相关资源
      最近更新 更多