html - CSS 在 Windows 上的显示与 Mac 不同

标签 html css windows macos nav

当我在 Windows 中查看站点时,站点的大部分内容(例如顶部文本、右侧联系方式详细信息、导航文本和欢迎文本)都比在 Mac 上显示的要低。 Mac 浏览器按应有的方式显示 CSS。请帮帮我...

Mac 截图

https://www.dropbox.com/s/qwe9hxfkfie3xqu/Mac%20screenchot.png

Windows 屏幕截图

https://www.dropbox.com/s/b9cnl3lczzrcmtp/Windows%20screenshot.png

HTML

<body>
<div id="wholepage">
<header>
<div id="nav_top">
<nav>
<h1 class="slogan">Steel & Fabrication Specialists</h1>
</nav>
</div>
<a href="index.html"><img class="kks_logo" src="KKSLogo.png" border="0" alt="KKS Services   Ltd logo"></a>
<h1 class="logo">KKS</h1>
<h2 class="logosub">Services Ltd</h2>
<h3 class="head_contact">0113 2826946</h3>
<h3 class="head_contact"><a href="contact.html">enquiries@kksservices.co.uk</a></h3>
<nav id="main_nav">
<ul id="nav_main">
 <li><a class="current_index" href="index.html">HOME</a></li>
 <li><a class="domestic" href="domestic.html">DOMESTIC</a></li>
 <li><a class="automation" href="automation.html">AUTOMATION</a></li>
 <li><a class="commercial" href="commercial.html">COMMERCIAL</a></li>
 <li><a class="contact" href="contact.html">CONTACT</a></li>
</ul>
</nav>
<img class="rivot" src="rivot.png" alt="KKS Services Ltd Rivot"/>
<img class="rivot2" src="rivot.png" alt="KKS Services Ltd Rivot"/>
<img class="rivot3" src="rivot.png" alt="KKS Services Ltd Rivot"/>
<img class="rivot4" src="rivot.png" alt="KKS Services Ltd Rivot"/>
</header>
<section>
<article>
<img class="railings" src="index_rail.png" alt="KKS Services Gates and Railings"/>
 <div id="welcome">
<h1 class="welcome">Welcome</h1>

CSS

.slogan{
position: relative;
width: 960px;
margin-left: auto;
margin-right: auto;
left: 10px;
top: -5px;
color: white;
font-size: 1.3em;
font-family: 'Aldrich', cursive;
}
.kks_logo{
position: relative;
top: 50px;
}
.head_contact{
font-family: 'Aldrich', sans-serif;
position: relative;
left: 10px;
top: -175px;
font-size: 1.5em;
text-align: right;
}
ul#nav_main li{
display: inline;
padding: 26px;
}
ul#nav_main li a{
text-decoration: none;
color: white;
font-family: 'Aldrich', sans-serif;
font-size: 1.4em;
position: relative;
top: 13px;
}
#welcome{
position: relative;
top: -267px;
left: 70px;
width: 840px;
height: 35px;
background-color: rgba(0,0,0,0.6);
border-radius: 5px;
}
#welcome h1{
color: white;
font-family: 'Aldrich', sans-serif;
padding: 10px;
font-size: 200%;
position: relative;
top: -5px;
left: 10px;
}

谢谢!

最佳答案

问题在于浏览器具有不同的默认样式。两种显示页面的方式都没有错,它们只是不同而已。

您已经对一种浏览器的默认样式进行了补偿,这使得它在所有其他浏览器中看起来都大不相同。只要您补偿默认样式而不是覆盖它们,您就会遇到这个问题。

例如,对于 .slogan 样式,您应该将顶部和底部边距设置为零,而不是使用相对定位来补偿默认边距。您可以使用 line-height 将文本在元素中垂直居中,而不是将其上下移动以将其置于中心。

例子:

.slogan{
  width: 960px;
  line-height: 30px;
  margin: 0 auto;
  color: white;
  font-size: 1.3em;
  font-family: 'Aldrich', cursive;
}

关于html - CSS 在 Windows 上的显示与 Mac 不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22700119/

相关文章:

c++ - 是否可以在 Windows 上运行时从可执行文件中定位函数?

java - 包 'au.com.bytecode' 不存在 (OpenCSV)

html - css的这两种方法有什么区别呢?

javascript - 防止浏览器缓存输入控件值

javascript - jquery 下拉菜单不适用于悬停

javascript - anchor 列表上的jquery单击事件

html - Bootstrap 4 - 粘性页脚 - 动态页脚高度

html - 如何对齐这些元素才能对齐?

javascript - 添加类名称中包含特定文本的类

c++ - 在 C++ 中,有什么方法可以强制进程的 WorkingSet 为 1GB?