0

在修复了调用它的 HTML 被我使用它的网站破坏后,我至少设法让关闭状态正确显示。但是幻灯片根本不会打开。这是CSS:

/**
 *  CSS3 Only Horizontal and Vertical Accordion
 *  Author: Paul Underwood for Hongkiat.com
 *  Website: www.paulund.co.uk
 *  Date: 27/11/11
 *  Version: 1.0
 */


article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; }
audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; }
audio:not([controls]) { display: none; }
[hidden] { display: none; }
html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
body { margin: 0; font-size: 13px; line-height: 1.231; }
body, button, input, select, textarea { font-family: sans-serif; color: #222; }

/*Define Accordion box*/
.accordion { width:700px; overflow:hidden; margin:10px auto; color:#474747; background:#414141; padding:10px; }

/*General Accordion****************************************************************************/
/*Set style of open slide*/
.accordion section:target { background:#FFF; padding:10px;}
.accordion section:target:hover { background:#FFF; }
.accordion section:target h2 {width:100%;}
.accordion section:target h2 a{ color:#333; padding:0;}
.accordion section:target p {display:block;}
.accordion section h2 a{padding:8px 10px;display:block; font-size:16px; font-weight:normal;color:#eee; text-decoration:none; }

/*set style of closed slide*/
.accordion section{ float:left; overflow:hidden; color:#139fec; cursor:pointer; background: #139fec; margin:3px; }
.accordion section:hover {background:#7fc5ec;}
.accordion section p { display:none; }
.accordion section:after{position:relative;font-size:24px;color:#000;font-weight:bold;}
.accordion section:nth-child(1):after{content:'1';}
.accordion section:nth-child(2):after{content:'2';}
.accordion section:nth-child(3):after{content:'3';}
.accordion section:nth-child(4):after{content:'4';}
.accordion section:nth-child(5):after{content:'5';}
/*End General Accordion****************************************************************************/

/*Horizontal Accordion *********************************************************************/
.horizontal section{ width:5%; height:250px; 
    -moz-transition:width 0.2s ease-out; 
    -webkit-transition:width 0.2s ease-out;
    -o-transition:width 0.2s ease-out;
    -ms-transition:width 0.2s ease-out;
    transition:width 0.2s ease-out;
}

/*Position the number of the slide*/
.horizontal section:after{top:140px;left:15px;}

/*Header of closed slide*/
.horizontal section h2 { 
    -webkit-transform:rotate(90deg);
    -moz-transform:rotate(90deg);
    -o-transform: rotate(90deg);
    -ms-transform: rotate(90deg);
    transform: rotate(90deg);
    width:240px; position:relative; left:-100px; top:85px;
} 

/*On mouse over open slide*/
.horizontal :target{ width:73%;height:230px; }
.horizontal :target h2{ top:0px;left:0;
    -webkit-transform:rotate(0deg);
    -moz-transform:rotate(0deg);
    -o-transform: rotate(0deg);
    -ms-transform: rotate(0deg);
    transform: rotate(0deg); 
}
/*End Horizontal Accordion *********************************************************************/

/*Vertical Accordion *************************************************************************/
.vertical section{ width:100%; height:40px;
    -webkit-transition:height 0.2s ease-out;
    -moz-transition:height 0.2s ease-out;
    -o-transition:height 0.2s ease-out;
    -ms-transition:height 0.2s ease-out;
    transition:height 0.2s ease-out;
}
/*Set height of the slide*/
.vertical :target{ height:250px; width:97%; }

.vertical section h2 { position:relative; left:0; top:-15px; }

/*Set position of the number on the slide*/
.vertical section:after{ top:-60px;left:810px;}
.vertical section:target:after{ left:-9999px;}

.accordion img{
    display:inline-block;
    width:211px;
    height:146px;
    border:1px solid white;
    vertical-align:top;
    margin-right:10px;
}

.accordion div{
    display:inline-block;
    width:311px;
}

这是HTML:

<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://static.tumblr.com/fq90l5c/7mhmmh2t0/style.css" /> 
<!--[if IE 8]>
<script src="http://static.tumblr.com/fq90l5c/2Csmn937d/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="accordion vertical"><section id="vertabout">
<h2><a href="#vertabout">Tutor-Led Course</a></h2>
<img src="image" height="146" width="211" />
<div>To view the tutor-led course information, please click <a href="link">here</a></div>
</section><section id="vertservices">
<h2><a href="#vertservices">E-Learning Module</a></h2>
<img src="image" height="146" width="211" />
<div>To view the E-Learning course information, please click <a href="link">here</a></div>
</section></div>
</body>
</html>

谁能明白为什么这在 IE8 中不起作用?我已经用 Firefox 对其进行了测试,它工作得很好。

4

2 回答 2

1

这里的主要问题是:target伪类仅在 IE9+ 中受支持。另一个会影响显示的问题是这些转换不会在 IE8 中呈现,但是,这可能只会影响手风琴的工作情况,而不是导致它根本无法工作。

目标支持来源:MDN

过渡支持来源:MDN

于 2013-05-23T13:16:01.370 回答
0

IE8 不支持 CSS 选择器 :target 和 :nth-child。您可以使用 polyfill 添加对 IE8 用户的支持(就像您通过添加对 HTML5 的支持一样html5shiv.js)。

我经常(阅读:总是)在我的项目中包含Selectivizr,以在 IE6-8 中创建对此类选择器的支持。

于 2013-05-23T13:27:18.803 回答