有关问题页面的实时视图,请转到此处:http://rcnhca.org.uk/sites/first_steps/health-safety-and-security/
问题1:如果您转到该链接并翻转下拉导航及其子项,您会注意到我在li
上的每个mouseenter
上为星形背景图像设置了动画。然而,第一次在IE8中滚动它时,即使我指定li
,它也会从background-position: -25px 50%;
的中间动画,奇怪的是,一旦jquery在内联中应用相同的设置,它就会按预期开始工作
问题2:正如您在下图中看到的,IE8 (这在IE7中正常工作)错误地呈现我的填充。我已使用core.css 中的* {margin: 0; padding: 0;}
重置所有边距和边距:
此导航栏的HTML标记为:
<header class="one">
<nav class="container_16 clearfix" id="breadcrumbs">
<a href="http://rcnhca.org.uk/sites/first_steps" id="home"></a>
<ul id="parent">
<li>
<a href="http://rcnhca.org.uk/sites/first_steps/communication/">Communication</a>
<ul class="child">
<li><a href="http://rcnhca.org.uk/sites/first_steps/getting-started/">Getting started</a></li>
<li><a href="http://rcnhca.org.uk/sites/first_steps/health-safety-and-security/">Health, Safety and Security</a></li>
<li><a href="http://rcnhca.org.uk/sites/first_steps/personal-and-people-development/">Personal and people development </a></li>
<li><a href="http://rcnhca.org.uk/sites/first_steps/quality/">Quality</a></li>
<li><a href="http://rcnhca.org.uk/sites/first_steps/equality-diversity-and-rights/">Equality, diversity and rights </a></li>
<li><a href="http://rcnhca.org.uk/sites/first_steps/clinical-skills/">Clinical skills</a></li>
<li><a href="http://rcnhca.org.uk/sites/first_steps/additional-material/">Additional material</a></li>
</ul>
</li>
<li>
<a href="#">Select a topic</a>
<ul class="child">
<li><a href="http://rcnhca.org.uk/sites/first_steps/communication/why-communication-is-important/">Why communication is important</a></li>
<li><a href="http://rcnhca.org.uk/sites/first_steps/communication/communication-methods/">Communication methods</a></li>
<li><a href="http://rcnhca.org.uk/sites/first_steps/communication/written-communication/">Barriers to communication</a></li>
</ul>
</li>
</ul>
</nav>
</header>
和要启动的CSS:
header {
width: 100%;
}
header.one {
height: 50px;
background: #44a9c4;
}
header.two {
height: 45px;
background: #3393b5;
}
/* =============================================================================
Breadcrumb navigation
========================================================================== */
#breadcrumbs {
padding: 0 3px 3px 0;
background: #ffffff;
border: 0px solid;
border-left: #3a90a7 2px solid;
border-right: #3a90a7 2px solid;
border-bottom: #3a90a7 2px solid;
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-radius-bottomleft: 5px;
-moz-border-radius-bottomright: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
#breadcrumbs #home{
display: block;
height: 39px;
width: 55px;
float: left;
background-image: url(library/images/home_icon.png);
background-repeat: no-repeat;
background-position: center;
text-indent: -999em;
}
#breadcrumbs ul#parent {
height: 39px;
width: 905px;
float: right;
position: relative;
background: #f38630;
border: 0px solid;
-webkit-box-shadow: inset 0px -2px 0px 0px #cf7229;
-moz-box-shadow: inset 0px -2px 0px 0px #cf7229;
box-shadow: inset 0px -2px 0px 0px #cf7229;
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-radius-bottomleft: 5px;
-moz-border-radius-bottomright: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
#breadcrumbs ul#parent li {
position: relative;
height: 39px;
float: left;
min-width: 1px; /* required to fix Opera bug */
padding: 0 47px 0 15px;
background-image: url(library/images/breadcrumb_seperator.png);
background-repeat: no-repeat;
background-position: right;
line-height: 39px;
}
#breadcrumbs ul#parent li a {
display: block;
height: 42px;
font-size: 0.938em;
font-weight:900;
letter-spacing: 0.01em;
color: #ffffff;
text-decoration: none;
text-shadow: 0px 2px 0px #cf7229;
}
#breadcrumbs ul li a:visited {
color: #ffffff;
}
#breadcrumbs ul#parent li:first-child ul {
left: -5px;
}
#breadcrumbs ul#parent li ul {
position: absolute;
z-index: 1;
left: -28px;
top: 42px;
background: #ffffff;
border-left: #3a90a7 2px solid;
border-right: #3a90a7 2px solid;
border-bottom: #3a90a7 2px solid;
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-radius-bottomleft: 5px;
-moz-border-radius-bottomright: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
.js #breadcrumbs ul#parent li ul {
display:none;
}
.no-js #breadcrumbs ul#parent li ul {
left: -999em;
}
#breadcrumbs ul#parent li ul li {
float: none;
height: 26px;
margin: 0 3px 3px 3px;
padding: 0 15px;
background-image: url(library/images/star-icon.png);
background-position: -25px center;
background-repeat: no-repeat;
background-color: #738793;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
line-height: 26px;
white-space: nowrap;
}
#breadcrumbs ul#parent li ul li a{
color: #ffffff;
text-decoration: none;
text-shadow: none;
letter-spacing: 0.01em;
font-weight: 100;
}
#breadcrumbs ul#parent li ul li:hover{
background-color: #3393b5;
}
.no-js #breadcrumbs ul#parent li ul li:hover{
background-position: 6px center;
text-indent: 10px;
}
#breadcrumbs ul#parent li:hover ul {
z-index: 2;
}
.no-js #breadcrumbs ul#parent li:hover ul {
left: -5px;
}
我花了很多年时间试图调试这个问题并且无法理解为什么会发生这种情况,如果有人能够对这个问题有所了解那就太好了。 (注意:我使用HTML5SHIV在旧版浏览器中呈现HTML5元素)
答案 0 :(得分:0)
我对错误是什么或为什么IE8以这种方式行事没有答案但是我设法通过从#home
和ul#parent
移除浮动并且绝对定位它们来克服边际问题相对于#breadcrumbs
并给它一个明确的高度,如下:
#breadcrumbs {
height: 39px;
padding: 0 3px 3px 0;
background: #ffffff;
position: relative;
border: 0px solid;
border-left: #3a90a7 2px solid;
border-right: #3a90a7 2px solid;
border-bottom: #3a90a7 2px solid;
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-radius-bottomleft: 5px;
-moz-border-radius-bottomright: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
#breadcrumbs #home{
display: block;
position: absolute;
top: 0px;
left: 0px;
height: 39px;
width: 55px;
float: left;
background-image: url(library/images/home_icon.png);
background-repeat: no-repeat;
background-position: center;
text-indent: -999em;
}
#breadcrumbs ul#parent {
height: 39px;
width: 885px;
position: absolute;
right: 3px;
top: 0px;
background: #f38630;
margin: 0px;
-webkit-box-shadow: inset 0px -2px 0px 0px #cf7229;
-moz-box-shadow: inset 0px -2px 0px 0px #cf7229;
box-shadow: inset 0px -2px 0px 0px #cf7229;
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-radius-bottomleft: 5px;
-moz-border-radius-bottomright: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
对于背景图像的问题,我创建了一个jquery函数,在加载后将背景位置添加到元素内联。
答案 1 :(得分:0)
使用HTML5Shiv
在IE 7-8中遇到了很多问题。如果html5标签是position:static
(浏览器默认值),那么当使用javascript动画/移动内容时,IE似乎有时无法重绘这些元素。大多数情况下,如果你能够在这些标签上加position:relative
,问题就会消失,因为IE似乎在相对定位的元素上正确触发hasLayout
。