0

我制作了一个垂直图像滑块,每个图像都是一个链接,当图像悬停时,一个不透明度为 0.4 的黑色“玻璃窗格”覆盖图像并显示一些文本。其实背景是透明的png

问题是它只能在谷歌浏览器中正确显示。

  • Opera:我只看到玻璃窗格,但看不到上面的文字
  • Firefox:我看不到玻璃窗格,但我仅在前 2 个项目中看到玻璃窗格上的文本,第三个文本未显示,并且图像之间的间距与 Google Chrome 和 Opera 显示的不同
  • IE:图片间距与谷歌浏览器和Opera显示的不同,hover什么都不做,不显示玻璃窗格,甚至不显示文本。

http://alessandroderoma.it/try/slider/

谷歌浏览器中显示的内容需要在所有其他浏览器中显示。

但是,这是我正在使用的 html 代码:

<div id="vertical_slideshowwrapper">
    <div class="vertical_slideshow" style="visibility: visible; overflow: hidden; position: relative; z-index: 2; left: 0px; height: 489px;">
        <ul style="margin: 0px; padding: 0px; position: relative; list-style-type: none; z-index: 1; height: 4564px; top: -1956px;">
            <li style="overflow: hidden; float: none; width: 165px; height: 489px;">
                <a href="#" target="_self">
                    <img src="images/1.png" border="0">
                    <div class="box"><p>Text 1</p></div>
                </a>
                <a href="#" target="_self">
                    <img src="images/2.png" border="0">
                    <div class="box"><p>Text 2</p></div>
                </a>
                <a href="#" target="_self">
                    <img src="images/3.png" border="0">
                    <div class="box"><p>Text 3</p></div>
                </a>
            </li>
            <li style="overflow: hidden; float: none; width: 165px; height: 489px;">
                <a href="#" target="_self">
                    <img src="images/4.png" border="0">
                    <div class="box"><p>Text 4</p></div>
                </a>
                <a href="#" target="_self">
                    <img src="images/5.png" border="0">
                    <div class="box"><p>Text 5</p></div>
                </a>
                <a href="#" target="_self">
                    <img src="images/6.png" border="0">
                    <div class="box"><p>Text 6</p></div>
                </a>
            </li>
            <li style="overflow: hidden; float: none; width: 165px; height: 489px;">
                <a href="#" target="_self">
                    <img src="images/7.png" border="0">
                    <div class="box"><p>Text 7</p></div>
                </a>
                <a href="#" target="_self">
                    <img src="images/8.png" border="0">
                    <div class="box"><p>Text 8</p></div>
                </a>
                <a href="#" target="_self">
                    <img src="images/9.png" border="0">
                    <div class="box"><p>Text 9</p></div>
                </a>
            </li>
        </ul>
    </div>
</div>

和CSS:

    body{
        background-color:#000;
    }
    DIV#vertical_slideshowfooter { 
        display:block; 
        padding-top: 10px; 
        font-family: Tahoma,Verdana,sans-serif; 
        font-size: 8px; 
        font-weight: bold; 
    } 
    div#vertical_slideshowwrapper { 
        width: 100%; 
        height: 100%; 
        overflow: hidden; 
        margin: 0px auto;  
    } 
    .vertical_slideshow ul li { 
        list-style:none; 
        margin-bottom:1px; 
        display:block; 
    } 
    .vertical_slideshow li img { 
        margin-right: 5px; 
        margin-top:1px; 
        margin-bottom:1px; 
        width: 160px; 
        height: 162px; 
    } 

    body{
        padding-top:0px;
        padding-left:0px;
        margin-top:0px;
        margin-left:0px;
    }

    .box {
        position: relative;
        left: 0;
        margin-top: -163px;
        width: 160px;
        height: 163px;
        background-image: url(images/bg.png);
        background-position:0 0;
        text-indent:-99999px;
    }

    .box:hover {
        background-position:-160px 0;
        text-indent:0;
    }

    .box p{
        position:absolute;
        font-family: Arial, Helvetica, Sans-Serif;
        bottom: -8px;
        right: 6px;
        font-variant: normal;
        font-weight: bold;
        font-size: 11px;
        text-align: left;
        text-decoration: none;
        text-transform: uppercase;
    }

    .box a, a:visited, a:hover{
        color:white;
        text-decoration:none;
    }

我究竟做错了什么?任何帮助,将不胜感激

CSS 验证器结果:

http://jigsaw.w3.org/css-validator/validator?uri=alessandroderoma.it%2Ftry%2Fslider&profile=css3&usermedium=all&warning=1&vextwarning=&lang=it

4

4 回答 4

2

放置在您的 html 页面的行首下方。

<!DOCTYPE html>  

类似的帖子

编辑
我认为歌剧中存在问题text-indent
我可以建议你一个答案。
最初使文本颜色为黑色,当悬停时使其变为白色

.box {  
    position: relative;
    left: 0;
    margin-top: -163px;
    width: 160px;
    height: 163px;
    background-image: url(images/bg.png);
    background-position:0 0;
    color:black;        /*added*/
    }   


.box:hover {
    background-position:-160px 0;
    text-indent:0;
    color:white;    /*added*/
}
于 2013-02-02T15:43:42.850 回答
0

只是一个建议:其他浏览器不支持某些 css 标签也许你可能想检查一下 IE http://www.quirksmode.org/css/condcom.html 你看看这个链接http://www。 quirksmode.org/css/contents.html

于 2013-02-02T15:30:35.003 回答
0

正如新开发人员所说,我添加了

<!DOCTYPE html>  

在我的 HTML 文档的顶部,它使我的 html 输出在所有浏览器上都非常相似,并使鼠标悬停在 css 上以与 IE 一起使用,但没有解决我的 Opera 问题,图像上的文本仍然没有被显示。我搜索了很多,我发现 Opera 仅对block元素启用文本缩进,但甚至添加

display: inline-block

我的.box元素并没有解决问题,所以我不得不找到一个解决方法。

我使用padding而不是解决了它text-indent

.box {
    padding-left: 99999px;
    overflow: hidden;
}

.box:hover {
    padding-left: 0px;
}

它有效,这不是一个解决方案,但对我来说这是一个很好的解决方法。

感谢所有帮助过的人!

于 2013-02-03T11:03:03.597 回答
-1

您可以使用背景颜色代替图像。因为您可以像图像一样设置背景颜色的透明度。将滑块的标题放入 div 类中,并为所需的输出写下以下代码。

.your_css_class
{
背景:#FDF7A6; /* 设置背景颜色 */
opacity: 0.5;/* 设置不透明度 */
}

还要记住设置 div 类的宽度、高度和位置。希望这对你有用。

于 2013-02-02T16:35:29.170 回答