【问题标题】:Working in Chrome, but not working in I.E. and Firefox. CSS/STYLE/HTML/PHP在 Chrome 中工作,但不在 IE 中工作。和火狐。 CSS/样式/HTML/PHP
【发布时间】:2011-12-24 11:03:45
【问题描述】:

我不知道如何解决这个烦人的问题。搜索和测试了很多,但没有任何效果。

嗯,我希望一切看起来都像谷歌浏览器的第一张图片。在 I.E.背景不同,标题不在中心。在 Firefox 中,这些框设置不正确。我想要每行 2 个盒子。

我不知道为什么会这样。

我不明白为什么 I.E.还在网上下载。。糟糕的浏览器

谁能帮帮我?

铬:

火狐:

I.E.

这里可以看到index.php

HTML/PHP

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
<link href="includes/style.css" rel="stylesheet" type="text/css" />
<title>-</title>

<style type="text/css">
/*<![CDATA[*/
#title{color:red; padding-bottom: 240px; padding-left: 25px;}
#desc{color:blue; padding-bottom: 135px; padding-left: 5px;}
/*]]>*/
</style>

<style type="text/css">
/*<![CDATA[*/
 div.c1 {width: 953px}
/*]]>*/
</style>
</head>

<body>
    <div class="header navpos c1" id="nav">
            <table summary="header" border="0">
                <tr>
                    <td>
                        <ul>
                            <li class="home"><a href="index.html"></a></li>
                        </ul>
                    </td>
                    <td>
                        <ul>
                            <li class="about"><a href="manage.html"></a></li>
                        </ul>
                    </td>
                    <td>
                        <ul>
                            <li class="contact"><a href="contact.html"></a></li>
                        </ul>
                    </td>
                    <td>
                        <ul>
                            <li class="twitter"><a href="index.html"><img src="includes/images/f_logo.png" alt="** PLEASE DESCRIBE THIS IMAGE **" /></a></li>
                        </ul>
                    </td>
                    <td>
                        <ul>
                            <li class="facebook"><a href="index.html"><img src="includes/images/t_logo.png" alt="link to Syndicate Plus Twitter" /></a></li>
                        </ul>
                    </td>
                </tr>
            </table>
    </div>
    <div class="box c1">
        <?php while($products = mysql_fetch_array($result)) {?>
        <table style="float: left;" width="473" align="left" background="includes/images/box.gif" width="473" height="285">
            <tr>
                <td width="35%" height="100%" id="title"><?php echo $products['products'];?></td>
                <td width="70%" height="100%" id="desc"><?php echo $products['description'];?></td>
            </tr>
        </table>
    <?php
    }       
    ?>
    </div>
    <div class="footer"></div>
</body>
</html>

这里可以看到style.css CSS***

* {
margin : 0;
padding : 0;
}
html {
background-image : url(images/web_bg.png);
}
body {
width : 953px;
margin : auto;
}
img {
border : 0;
}
A:link {
text-decoration : none;
color : #0087dc;
}
A:visited {
text-decoration : none;
color : #0087dc;
}
A:hover {
text-decoration : none;
color : #0087dc;
}
a:active, a:focus {
outline : 0;
}
a {
outline : none;
}
.header {
background-image : url(images/header_bg.png);
width : 953px;
margin : auto;
}
.footer {
background-image : url(images/bot_new.png);
min-height : 229px;
max-height : 229px;
position: relative;
}
#nav {
float : left;
}
#nav li {
float : left;
list-style-type : none;
}
#nav .home a {
margin-left : -20px;
margin-top : 25px;
display : block;
background-image : url(images/header_home.png);
background-repeat : no-repeat;
width : 400px;
height : 54px;
}
#nav .about a {
margin-left : 300px;
margin-top : 30px;
display : block;
background-image : url(images/header_about.png);
background-repeat : no-repeat;
width : 64px;
height : 13px;
}
#nav .contact a {
margin-left : 20px;
margin-top : 30px;
display : block;
background-image : url(images/header_contact.png);
background-repeat : no-repeat;
width : 64px;
height : 13px;
}
#nav .twitter a {
margin-left : 40px;
margin-top : 30px;
display : block;
background-image : url(images/t_logo.png);
background-repeat : no-repeat;
width : 26px;
height : 26px;
}
#nav .facebook a {
margin-left : 5px;
margin-top : 30px;
display : block;
background-image : url(images/f_logo.png);
background-repeat : no-repeat;
width : 26px;
height : 26px;
}
#nav .home a:hover {
margin-left : -20px;
margin-top : 25px;
background : url(images/header_home_light.png);
background-repeat : no-repeat;
width : 400px;
height : 54px;
}
#nav .about a:hover {
margin-left : 300px;
margin-top : 30px;
background : url(images/header_about_light.png);
background-repeat : no-repeat;
width : 64px;
height : 13px;
}
#nav .contact a:hover {
margin-left : 20px;
margin-top : 30px;
background : url(images/header_contact_light.png);
background-repeat : no-repeat;
width : 64px;
height : 13px;
}

【问题讨论】:

  • 有什么问题?您想要的效果是什么,什么不起作用?光看截图很难判断。
  • 根据屏幕截图,实际上看起来 Chrome 和 IE 都在工作,而 Firefox 是糟糕的继子。您能否更详细、更准确地描述问题,并尽可能排除您的偏见?
  • 好吧,我希望一切看起来都像第一张图片 Google Chrome。在 I.E.背景不同,标题不在中心。在 Firefox 中,这些框设置不正确。我想要每行 2 个盒子。

标签: html css internet-explorer firefox google-chrome


【解决方案1】:

试试display: inline-block;

不确定,因为未测试。

【讨论】:

  • 你的意思是 style.css 对吧?我改变了所有的显示:块;显示:内联块;。不过没有区别
【解决方案2】:

将页眉、内容和页脚包裹在一个恒定宽度的&lt;div&gt; 中,以强制在某个点出现下一行。

<body>
<div id="wrapper">
  <div id="header">header</div>
  <div id="content">
      <script type="text/javascript">
        for (i=0;i<5;i++) { // example in javascript
          document.write("<div style='float:left;width:80px;height:80px;background-color:blue;margin:2px;'></div>");
        }
      </script>
  </div>     
  <div id="footer">footer</div>    
</div>
</body>

CSS:

body {
   text-align:center;
}
#wrapper {
    background-color:#eee;
    width:300px;
    margin: 0 auto;
    text-align:left;
}
#header {
    background-color:red;
}
#content {
}
#footer {
    clear:both;
    background-color:green;
}

工作代码和结果: http://jsfiddle.net/fsHd5/3/

【讨论】:

  • 曾为 I.E.但是在IE中一切都与左对齐。Firefox中没有发生任何事情。还有更多提示吗?
  • @F4LLCON style="margin: auto 0;"将外部 div 居中
  • 这个对吗?完全没有效果..这是奇怪的部分,我之前试过这个没有奏效。就像代码讨厌我一样
  • 对于这个解决方案,您还需要删除您设置的正文宽度和边距。否则,您可能会将 950px 块居中在 953px 块中,差别不大。
  • 在 I.E.它现在在中心。但是为什么每次刷新时背景图像都会改变样式?随机,显示背景图,下次不显示,下次显示一部分。在IE中按F5后在 Firefox 中仍然没有效果。
【解决方案3】:

对于您的 IE 问题,您告诉 #nav 向左浮动。没有真正的需要。我假设您打算将其应用于子元素。 IE 确实存在背景仅扩展到内容高度的问题。除了明确设置高度的有点骇人听闻的解决方案之外,我对此没有任何解决办法。

在 Firefox 中,它不会强制设置正文的宽度,因此请在其周围使用 div 将宽度强制为您想要的宽度。

【讨论】:

  • 当我更改 #nav float 时什么也没发生。我用 div 来强制它,yosh 告诉我,但是是的.. 不能正常工作
  • 在尝试这些时也删除正文宽度。
  • 无论如何,谢谢,我将以适当的方式重写代码。看看现在有了这些信息的结果。
  • 好电话。更多建议:使用 css 设置宽度,而不是 width 属性。与身高相同。一般来说,如果你能用css做到,那就去做吧。此外,您目前使用 70% 和 35% 的 td 宽度。这些加起来超过 100%。
  • 谢谢,没注意是105%。我现在将制作一个干净的版本,希望它会成功。
猜你喜欢
相关资源
最近更新 更多
热门标签