css - 简单的 CSS 图像悬停问题

标签 css image hover

我在将此代码实现到我的网站时遇到问题 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; }

最佳答案

原来是格式错误 -/链接全错了。对于其他有类似问题的人来说,这是正确的代码......

    <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>

关于css - 简单的 CSS 图像悬停问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5036446/

相关文章:

html - 如何将 div 扩展到页面底部?

image - SwiftUI、CloudKit 和图像

css - 将图像垂直/水平居中放置在另一个没有尺寸的图像上

html - css 悬停在链接上 - 不起作用

java - 将鼠标悬停在动画菜单上并单击 selenium 中的菜单项

html - 是否有可能以某种方式在表格行周围设置边框?

css - 如何正确设置 MX 列表的 Angular 半径并获得圆 Angular ?

javascript - HSL 随机颜色将其应用于函数

javascript - 从单独的 JS 文件访问 Play 框架模板属性

css - 溢出隐藏无法正常使用半径边界