0

我正在尝试链接图像,在 html 中如下所示:

<a href="#" class="image"><img src="logo.png"></a>

在 CSS 中我有:

.baraMeniu a.image{
    display:block;
}

是的... display:block 只是使图像可点击的尴尬尝试。我是初学者,所以请一步一步来。

编辑:我忘了说我的图像具有以下属性:

.baraMeniu img{
    width:100%;
    height:40em;
    position:absolute;
    z-index:0;/*the image*/
}
.baraMeniu a.image{
    /*the clickable image*/
}
.baraMeniu .st{
    font-size:2em;
    padding-top:0.15em;
    padding-left:0.7em;
    padding-right:0.5em;
    color:orange;
    font-family:'Century Gothic', CenturyGothic, AppleGothic, sans-serif;
    display:inline;
    text-decoration:none;
    float:left;
}
.baraMeniu .dr{
    font-size:2em;
    padding-top:0.15em;
    padding-left:0.7em;
    padding-right:0.5em;
    color:orange;
    font-family:'Century Gothic', CenturyGothic, AppleGothic, sans-serif;
    display:inline;
    text-decoration:none;
    float:right;
}

.baraMeniu #ind{
    text-indent:20px;
}
4

1 回答 1

0

如果您尝试<a>在图像周围加上标签,则不需要任何特殊技巧。

<a href="SomeLink.html"><img src="logo.png"></a>

那会很好用。

您可以稍后使用 CSS 或 JS 更改其外观、悬停效果等。

为清楚起见进行编辑。而不是通过页面上的元素来定位您的图像,例如,a.img.classwhatever{}为了简单起见,我只会给它一个自己的类或将它放在一个 div 中。将 CSS 应用于类或 ID。

<div class="ImageLink">
<a href="SomeLink.html"><img src="logo.png"></a>
</div>

至于Z-index,请注意。负面意味着它落后于其他一切。

于 2015-06-11T20:23:00.043 回答