【问题标题】:CSS issue with top margin in safariSafari中上边距的CSS问题
【发布时间】:2012-02-09 08:19:05
【问题描述】:

我无法在 Safari 中显示上边距。 CSS 工作正常,#divcontainer 有一个上边距,在 firefox 和其他浏览器中居中,但在 safari 中不居中。

我希望在容器上方显示一个 10 像素的空间,以容纳所有其他内容。

这是 CSS:

/* CSS Document */

body {

    color: #000000; /*This sets all text to Black*/
    /*background-color: #FFFFFF; /*This sets the bacground to white*/
    margin: 100px auto; /*This sets the margin to zero*/
    padding:0;
    font-size:12px;
    font-family:Verdana, Arial, Helvetica, sans-serif;
    text-align:center;
}
p {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #000000;
}
h1 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #000099;
}
h2 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #000099;
}
h3 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #000099;
}
.redtext {
    color: #FF0000;
}
a {
    color: #009900;
}
a:link {
    color: #000099;
    text-decoration: underline;
}
a:visited {
    color: #666666;
    text-decoration: none;

}
a:hover {
    text-decoration: none;
    background-color: #CCCCCC;
}
a:active {
    text-decoration: none;

}

.menu {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
    color: #000000;
}
.menu a:link {
    color: #336600;
    text-decoration: none;
}
.menu a:visited {
    color: #666666;
    text-decoration: none;
}

.menu a:hover {
    color: #990000;
    text-decoration: none;
}

.menu a:active {
    color: #666666;
    text-decoration: none;
}
div#container {
    width: 960px;
    height:760;
    overflow:auto;
    /*margin-left:0 auto; /* the auto value on the sides, coupled with the width, centers the layout */

}
div#outer {
    margin-left: auto;
    margin-right: auto;
    width: 960px;
}
div#header {
    position:relative;
    text-align: center;
    width: auto;
}
div#nav {
    width: auto;
    padding: 10px;
    margin-top: 1px;
    position:relative;
}
div#main {
    position:relative;
    width: auto;
}
div#footer {
    position:relative;
    width:auto;
    padding: 15px;
    margin: 0px;
}#nav {
    position: relative;
    padding:20px;
    width: auto;
}

【问题讨论】:

  • 你也可以发布html吗?
  • 在 div#container 的高度中,您还需要在 760 之后使用 'px',但我建议不要尝试将高度作为一般规则。
  • 新站点

标签: css safari margin


【解决方案1】:

您可能需要设置边距:10px auto;在#container 上。通常,我会这样做:

body {
 text-align: center;
 padding: 0;
 margin: 0;
}

#container {
  width: 960px;
  height: 760px;
  text-align: left;
  margin: 10px auto;
}

...假设#container div 是第一个元素,这应该可以解决。

您可能还想尝试其中一个 css 重置文件。

【讨论】:

  • html 不发达我试图让主容器正确显示并从那里开始是 html
猜你喜欢
  • 2017-10-02
  • 2011-07-04
  • 1970-01-01
  • 2016-08-15
  • 2016-10-16
  • 1970-01-01
  • 2019-07-25
相关资源
最近更新 更多