简单的 CSS 图像悬停问题

发布于 2024-10-18 06:04:01 字数 2451 浏览 1 评论 0原文

我在网站 http://www.some-things.net 上实现此代码时遇到问题/category/work/

http://www .sohtanaka.com/web-design/css-on-hover-image-captions/

任何人都可以看到我哪里出了问题吗? 我已经让它在 coda 中工作了——但是当我尝试将它实现到 wordpress 中时,有些东西坏了。

    <div style="clear:both"></div>
        <div class="gallery">
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                <div class="portfolioItem">
                        <a href="<?php the_permalink() ?>" title="<?php the_title();?>"><?php the_post_thumbnail(); ?></a>
                <span class="desctitle"><h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
</span> </div>
<?php endwhile; ?>
</div>

这是 CSS:

    .portfolio {overflow:hidden;}
.gallery {
    margin-top:10px;
    padding-left:22px;
    margin-left:-22px;
    margin-bottom:20px;
    width:982px;
}

/* .portfolioItem {
    float:left;
    width:300px;
    margin-right:25px;
    overflow:hidden;
    margin-bottom:5px;
} */

.portfolioItem {
    float: left;
    overflow: hidden;
    position: relative;
    margin-right: 25px;
    margin-bottom: 5px;
}



.portfolioItem a {
    text-decoration: none;
    float: left;
}
.portfolioItem a:hover {
    cursor: pointer;
}



 /* .portfolioItem img {
    border:2px;
    border-color:000;
    border-style:solid; */
    /* border:none; */
    /* opacity:0.6;filter:alpha(opacity=60);} */


/* .gallery .portfolioItem img:hover {
opacity:1;filter:alpha(opacity=100);}
*/  


.portfolioItem a img {
    float: left;
    margin: 0;
    border: none;

}



/* boxes for portfolio item descriptions */


.portfolioItem a:hover .desctitle {
    display: block;
    font-size: 1.2em;
    padding: 0px 0;
    background: #111;
    filter:alpha(opacity=75);
    opacity:.75;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=75)"; /*--IE 8 Transparency--*/
    color: #fff;
    position: absolute;
    bottom: 0px;
    margin: 0;
    width: 300px;
    border-top: 1px solid #999;

}


/* .desctitle a {
    color:white;
    padding-left:12px;

    }
*/


.portfolioItem a .desctitle {   display: none; }

I'm having problems implementing this code onto my site http://www.some-things.net/category/work/

http://www.sohtanaka.com/web-design/css-on-hover-image-captions/

Can anyone see where I'm going wrong?
I've got it working in coda - but when I try implement it into wordpress, something breaks.

    <div style="clear:both"></div>
        <div class="gallery">
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                <div class="portfolioItem">
                        <a href="<?php the_permalink() ?>" title="<?php the_title();?>"><?php the_post_thumbnail(); ?></a>
                <span class="desctitle"><h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
</span> </div>
<?php endwhile; ?>
</div>

And here is the CSS:

    .portfolio {overflow:hidden;}
.gallery {
    margin-top:10px;
    padding-left:22px;
    margin-left:-22px;
    margin-bottom:20px;
    width:982px;
}

/* .portfolioItem {
    float:left;
    width:300px;
    margin-right:25px;
    overflow:hidden;
    margin-bottom:5px;
} */

.portfolioItem {
    float: left;
    overflow: hidden;
    position: relative;
    margin-right: 25px;
    margin-bottom: 5px;
}



.portfolioItem a {
    text-decoration: none;
    float: left;
}
.portfolioItem a:hover {
    cursor: pointer;
}



 /* .portfolioItem img {
    border:2px;
    border-color:000;
    border-style:solid; */
    /* border:none; */
    /* opacity:0.6;filter:alpha(opacity=60);} */


/* .gallery .portfolioItem img:hover {
opacity:1;filter:alpha(opacity=100);}
*/  


.portfolioItem a img {
    float: left;
    margin: 0;
    border: none;

}



/* boxes for portfolio item descriptions */


.portfolioItem a:hover .desctitle {
    display: block;
    font-size: 1.2em;
    padding: 0px 0;
    background: #111;
    filter:alpha(opacity=75);
    opacity:.75;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=75)"; /*--IE 8 Transparency--*/
    color: #fff;
    position: absolute;
    bottom: 0px;
    margin: 0;
    width: 300px;
    border-top: 1px solid #999;

}


/* .desctitle a {
    color:white;
    padding-left:12px;

    }
*/


.portfolioItem a .desctitle {   display: none; }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘东忘西忘不掉你 2024-10-25 06:04:01

结果发现这是一个格式错误 - / 链接完全错误。对于其他有类似问题的人来说,这是正确的代码......

    <div style="clear:both"></div>
        <div class="gallery">
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                <div class="portfolioItem">
                        <a href="<?php the_permalink() ?>" class="desctitle" title="<?php the_title();?>"><?php the_post_thumbnail(); ?>
                <span class="desctitle"><?php the_title(); ?></a>
</span>                     

                    </div>

            <?php endwhile; ?>
        </div>

It turned out to be a formatting error - the / linking was all wrong. This is the correct code for anyone else with a similar problem...

    <div style="clear:both"></div>
        <div class="gallery">
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                <div class="portfolioItem">
                        <a href="<?php the_permalink() ?>" class="desctitle" title="<?php the_title();?>"><?php the_post_thumbnail(); ?>
                <span class="desctitle"><?php the_title(); ?></a>
</span>                     

                    </div>

            <?php endwhile; ?>
        </div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文