简体   繁体   English

Firefox中的CSS与Google Chrome看起来不同,该怎么办?

[英]CSS looks different in Firefox than Google Chrome, what can I do?

For fun, I am doing a table with two cells in each row. 为了好玩,我正在做一张表格,每行有两个单元格。 And I want the cells in the first row to have the same picture, so I wrote in CSS: 我希望第一行中的单元格具有相同的图片,所以我在CSS中写道:

tr:nth-child(1){
background-image:url("cat.jpg");
background-size:cover;
border-radius:10px;
}

And my HTML code looks like this: 我的HTML代码如下所示:

<tr>
  <td>Ruta 1</td>
  <td>Ruta 2</td>
</tr>
<tr>
  <td>Ruta 3</td>
  <td>Ruta 4</td>
</tr>

So, you should have the same picture on each cell, which I have in Google Chrome. 因此,您在每个单元格上应该有相同的图片,而我在Google Chrome中也是如此。 But when I use this in Firefox, I get the same picture over two cells. 但是,当我在Firefox中使用它时,我在两个单元格上得到了相同的图片。

Google Chrome , and Firefox . Google ChromeFirefox

Any clue of what this is about? 关于这是什么线索? Can I write something in my CSS do make it work for Firefox. 我可以在CSS中写一些东西使其在Firefox上运行吗? thanks in advance! 提前致谢!

In firefox don't set background-image or color in tr, It will make problems. 在firefox中,不要在tr中设置背景图像或颜色,这会造成问题。 Instead add to td. 而是添加到td。

tr:nth-child(1) td{background-image:url("cat.jpg");}

Apply background to cells - <td> and not to rows - <tr> . 将背景应用于单元格- <td>而不应用于行- <tr>

tr:nth-child(1) td {
    background-image:url("cat.jpg");
    background-size:cover;
    border-radius:10px;
}

You want each cell to have its own picture, not each row . 您希望每个单元格都有自己的图片,而不是每一

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

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