English 中文(简体)
只有链接框中的文本可以点击
原标题:Only text in link box is clickable

我在网页上有一张缩略图列表, 上面有链接框。 这些缩略图由链接标签包裹, 可以点击。 但是, 在链接框上面有略为透明背景的链接框中, 只有文本, 而不是整个框可以点击 。

这是一套缩略图和链接框的 HTML 代码 :

<article class="recent-post-item">
    <h2>
        <a  href="link/to/somewhere" title="Permanent link to Something">Something</a>
    </h2>
    <a href="link/to/somewhere" title="Something" class="thumb">
        <img src="someimage.png" alt="Something" width="248" height="125" />
    </a>
</article>

这是相应的样式表 :

#column-2 .recent-post-item {
    height: 127px;
    width: 250px;
    position: relative;
    border: none;
}
#column-2 .thumb {
    margin: 0;
    position: absolute;
    top: 0px;
    left: 0px;
}
#column-2 h2 {
    font-size: 22px;
    background-color:rgba(255,255,255,0.6);
    padding: 5px 4px;
    margin: 0;
    position: absolute;
    z-index: 1;
    bottom: 1px;
    left: 1px;
    right: 1px;
}

这里有一个工作网站来展示问题:http://fuckthepony.dk/wordpress/ (我所说的缩略图是中栏中的缩略图)

有些人告诉我,他们没有遇到这个问题。 我在Linux上用歌剧、铬和火狐测试过,所有这些浏览器都存在这个问题。

最佳回答

我同意上述意见,但为了使整个透明区块能够被点击,你还需要把h2的垫子取下来,然后在标签上加上垫子。

#column-2 h2 {
    padding: 0;
}

#column-2 h2 a {
    display: block;
    padding: 5px 4px;
}
问题回答

This is because a elements are inline elements, so they don t take all parent s width available. You can add this rule to your css:

#column-2 h2 a {
    display: block;
}

s 只是因为元素没有显示: 默认屏蔽 。

添加这一小行:

#column-2 h2 a { display:block; }




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签