简体   繁体   English

CSS浏览器兼容性问题- <hr />

[英]CSS Browser Compatibility Issue - <hr />

In my HTML I have this table setup which is composed of separated images for each table cell. 在我的HTML中,我有此表设置,该表设置由每个表单元格的单独图像组成。 I have a < hr /> break at the bottom of the div, separating the table from the rest of the content. 我在div的底部有一个<hr />中断,将表格与其余内容分开。 When I test on Chrome it shows correctly, however in Firefox the line break isn't aligned properly, it's pushed up a few pixels. 当我在Chrome上测试时,它可以正确显示,但是在Firefox中,换行符未正确对齐,因此将其向上推了几个像素。

The second issue is with the images. 第二个问题是图像。 Between the second and third table cells, there is a gap of white space, about 2px wide, separating the images. 在第二个和第三个表单元格之间,有大约2px宽的空白间隙,将图像分开。

I'm not exactly sure if this is browser compatibility issue, but how do I fix it? 我不确定这是否是浏览器兼容性问题,但是如何解决?

http://jsfiddle.net/Fe7DC/ - JSfiddle with the code http://jsfiddle.net/Fe7DC/-带有代码的JSfiddle

<div class="fade" id="Latest-Stories">
               <h3 class="section-header"> Son Xəbərlər </h3>
                     <table id="stories-preview" width="330" height="598" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                   <td id="tablecell1"><a id="link_1"> <img id="img1" src="NewsBarAZ/Article-Nav-Bar2_01.gif"  alt="" /></a></td>
                            </tr>
                            <tr>
                                   <td id="tablecell2"><a id="link_2" ><img id="img2"  src="NewsBarAZ/Article-Nav-Bar1_02.gif" alt="" /> </a></td>
                            </tr>
                            <tr>
                                   <td id="tablecell3"><a id="link_3" ><img id="img3" src="NewsBarAZ/Article-Nav-Bar1_03.gif"  alt="" /></a></td>
                            </tr>
                            <tr>
                                   <td id="tablecell4"><a id="link_4" ><img id="img4" src="NewsBarAZ/Article-Nav-Bar1_04.gif" alt="" /></a></td>
                            </tr>
                            <tr>
                                   <td id="tablecell5"><a id="link_5" ><img id="img5" src="NewsBarAZ/Article-Nav-Bar1_05.gif" alt="" /></a></td>
                            </tr>
                     </table>
   </div>
   <hr />
#Latest-Stories {
    width:1000px;
    height:598px;
    padding-bottom:36px;
    background-color:#FFF;
    padding-left:20px;
}
#stories-preview {
    float:right;
    border-left:2px groove;
    border-right:2px groove;
    border-top:2px groove;
    border-bottom:1px solid #9A9A9A;
}

I must say that i am not a big fan of using tables for non tabular data, a list would probably be more appropriate here. 我必须说,我不是将表用于非表格数据的忠实拥护者,在这里使用列表可能更合适。 That is besides the question however. 但是,那除了问题。

The implementation of hr is very browser dependent and therfore i hardly ever use it (wait till you start testing in IE...). hr的实现非常依赖于浏览器,因此我几乎从未使用过它(请等到您开始在IE中进行测试...)。 My advise would be to replace it with a div with a class of .hr and style it to your wishes in css. 我的建议是将其替换为带有.hr类的div并在css中根据您的意愿设置样式。

An example: 一个例子:

<div class='.hr'></div>

.hr {
  padding-top: 5px;
  border-bottom: 1px solid #000;
  margin-bottom: 5px;
}

If you are not happy with the default border, you could even use a small image and repeat it along the x axis. 如果您对默认边框不满意,甚至可以使用小图像并沿x轴重复。 Don't forget to give your div some height in this case though. 不过,在这种情况下,请不要忘记为div设置一些高度。

As for the gap between the images, I do not have an imediate explanation for this. 至于图像之间的差距,我对此没有直接的解释。 Perhaps it has to do with the actual images, that might have some transparent pixels on the top or bottom. 可能与实际图像有关,在顶部或底部可能有一些透明像素。 Hard to tell without the actual images though. 没有实际的图像很难说。

Normally I add css styling to my hr elements: 通常我会在hr元素中添加CSS样式:

line-height: 0.01;  
height: 1pt;  
border: 1pt solid black;  
border-width: 0 0 1pt 0;  
background: transparent;

And to avoid problems with erroneous spacing between cells and rows, I usually omit ALL whitespace from between the tags in my source code. 为了避免单元格和行之间的错误间距问题,我通常在源代码中的标记之间省略了所有空格。 Yes, makes for a difficult read, but some browsers just refuse to behave. 是的,很难阅读,但是某些浏览器只是拒绝表现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM