简体   繁体   English

如何使可点击的div内具有鼠标悬停图像链接?

[英]How to make a clickable div with a rollover image-link inside of it?

I'm trying to make a clickable div hold my rollover image link inside of it. 我正在尝试使一个可点击的div将鼠标悬停图像链接保存在其中。 I already have the rollover image inside of it, but the whole div isn't turning into a clickable link. 我已经在其中有了过渡图像,但是整个div都没有变成可点击的链接。

The html looks like this: html看起来像这样:

 <div class="left1" id="range-logo">
 <div class="left1button"> <a href="#"></a> </div>               
 </div>

My rollover image link is functioning, but the div that's holding that rollover image link isn't turning into a link. 我的过渡图像链接正在运行,但是保存该过渡图像链接的div并未变成链接。 I want the whole thing to be a link/clickable. 我希望整个事情是一个链接/可点击的。

What I'm trying to achieve by doing this, is having a clickable div with a background image (#range-logo is giving it the background). 我要通过这样做来实现的目的是要使一个具有背景图片的可点击div(#range-logo为其赋予背景)。 I want that background image to change when hovered over. 我希望将鼠标悬停在该背景图像上进行更改。 And also, inside of that div, I want an image rollover link. 而且,在该div内部,我想要一个图像翻转链接。

Site I'm working on can be found here: 我正在处理的网站可以在以下位置找到:

http://shopmoonfall.bigcartel.com/ http://shopmoonfall.bigcartel.com/

I'm working on the first div underneath the big slider (first girl with sunglasses). 我正在大滑块下面的第一个div(第一个戴墨镜的女孩)工作。

ok I think I unserstand, it's hard to give you exact code with out anything posted but use 好的,我认为我不太了解,很难在没有使用任何已发布内容的情况下为您提供准确的代码

#range-logo:hover a{
    background-color: #FFF
    //add whatever styles you want on that tag
}

EDIT Just use an a tag and add id="range-logo" to it. 编辑只需使用a标签,然后向其添加id="range-logo" a 's are inline-block by nature so if you want it to behave like a div use display: block; a本质上是inline-block ,因此如果您希望它的行为类似于div,请使用display: block; . Now you don't need that second a tag inside, use a div and add a class to it 现在您不需要里面a标签,使用div并向其中添加一个类

<a class="left1" id="range-logo" href="/products">
    <div class="left1button"> <div class="someName"></div></div>             
</a>

EDIT 2 编辑2

you have this script that's targeting an a inside of .left1button 你有这样的脚本的定位的a内部.left1button

.left1button a {
   display: block;
   width: 158px;
   height: 37px;
   top: 175px;   
   left: 75px;
   background-image: url(http://oi40.tinypic.com/2zfr7h4.jpg);
}

So you can do 1 of 2 things, you can use <div></div> instead of <a href="#"></a> and change the above target to be .left1button div or you can remove that whole thing and use something like 因此,您可以执行2件事中的1件事,可以使用<div></div>代替<a href="#"></a>并将上述目标更改为.left1button div ,也可以删除整个内容并使用类似

.someName { //Call this whatever you want
   display: block;
   width: 158px;
   height: 37px;
   top: 175px;   
   left: 75px;
   background-image: url(http://oi40.tinypic.com/2zfr7h4.jpg);
}

and then you can use my example above. 然后您可以使用上面的示例。 Whatever you want 无论你想要什么

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM