CSS IE8无法设置列表元素的样式

时间:2022-11-20 21:24:28

I'd like to make an ordered list, centered and without bullets. The big gap is that I can't stylize it into explorer 8. It doesn't align horizontally, while in all other browser it does. I read a lot around the web, but I couldn't find the solution. My last trying has been to copy the code I found here in "stack overflow", Horizontal Lists without floating the LI but also in this way I couldn't get it to work. Please help me! I'll post my code here HTML:

我想制作一个有序列表,居中并且没有子弹。差距很大,我无法将其设置为资源管理器8。它不会水平对齐,而在所有其他浏览器中它都可以。我在网上看了很多,但我找不到解决方案。我最后的尝试是复制我在“堆栈溢出”中找到的代码,水平列表没有浮动LI,但也是这样我无法让它工作。请帮帮我!我会在这里发布我的代码HTML:

<nav class="orizNav">
        <ul>
    <li><a href="onoranze.php" name="noi"><h3>chi siamo</h3></a></li>
    <li><a href="servizi.php" name="servizi"><h3>servizi</h3></a></li>
    <li><a href="epigrafiol.php" name="epigrafionline"><h3>epigrafi on line</h3></a></li>
    <li><a href="contatti.php" name="contatti"><h3>contatti</h3></a></li>
    <li><a href="index.php" name="inizio"><h3>inizio</h3></a></li>
    </ul>
</nav>

and here the CSS

这里是CSS

.orizNav ul {
list-style: none;
padding-bottom: 10px;
height:16px;
}
.orizNav ul li {
position: relative;
display: inline-block;
*display: inline;
zoom: 1;
}
.orizNav {
position: relative;
margin-top: -30px;
text-align: center;
font-family: Fog;
font-size: 14px;
}

2 个解决方案

#1


15  

Your problem is not with your CSS but rather with the HTML5 <nav> tag that you've added, IE8 doesn't recognise that as a valid HTML tag.

您的问题不在于您的CSS,而在于您添加的HTML5

Just stick this block of code in the head of your document:

只需将这段代码粘贴在文档的头部:

<!--[if lt IE 9]>
<script>
document.createElement('header');
document.createElement('nav');
document.createElement('section');
document.createElement('article');
document.createElement('aside');
document.createElement('footer');
document.createElement('hgroup');
</script>
<![endif]-->

And add this piece of CSS to make IE behave.

并添加这段CSS以使IE表现。

CSS

CSS

header, nav, section, article, aside, footer, hgroup { 
   display: block;
}

#2


0  

Try adding this in your css file

尝试在您的css文件中添加它

header, nav, article, footer, address {  
    display: block;  
}

http://jsfiddle.net/alleks/n8z6W/

http://jsfiddle.net/alleks/n8z6W/

#1


15  

Your problem is not with your CSS but rather with the HTML5 <nav> tag that you've added, IE8 doesn't recognise that as a valid HTML tag.

您的问题不在于您的CSS,而在于您添加的HTML5

Just stick this block of code in the head of your document:

只需将这段代码粘贴在文档的头部:

<!--[if lt IE 9]>
<script>
document.createElement('header');
document.createElement('nav');
document.createElement('section');
document.createElement('article');
document.createElement('aside');
document.createElement('footer');
document.createElement('hgroup');
</script>
<![endif]-->

And add this piece of CSS to make IE behave.

并添加这段CSS以使IE表现。

CSS

CSS

header, nav, section, article, aside, footer, hgroup { 
   display: block;
}

#2


0  

Try adding this in your css file

尝试在您的css文件中添加它

header, nav, article, footer, address {  
    display: block;  
}

http://jsfiddle.net/alleks/n8z6W/

http://jsfiddle.net/alleks/n8z6W/