简体   繁体   English

CSS悬停在整个表格行中创建热点

[英]CSS hover creating hotspot in entire table row

I recently applied a hover feature to a set of buttons. 我最近将鼠标悬停功能应用于一组按钮。 When applied to a different website the coding was fine. 当应用到其他网站时,编码很好。 When applied to this site the link/hotspot goes to the next button. 当应用于该站点时,链接/热点将转到下一个按钮。 For example: I have buttons home/about/gallery/blog/prints/contact and you would think with the dimensions set in CSS style sheet that the link would only apply to those dimensions. 例如:我有home / about / gallery / blog / prints / contact按钮,您会认为CSS样式表中设置的尺寸是该链接仅适用于这些尺寸。 Not with this one. 没有这个。 The link/hotspot shows linked to index.shtml from the edge of the table to the other side of the home button. 链接/热点显示从表的边缘到主页按钮另一侧的链接到index.shtml的链接。 There are spaces between buttons but the link/hotspot goes 50%across the space until it hits the next buttons link/hotspot. 按钮之间有空格,但链接/热点在该空间中的距离为50%,直到命中下一个按钮链接/热点。 And the final button "contact" spans across to the opposite edge of the table. 最后一个按钮“接触”跨到桌子的另一边。 Any clues as to what I am doing wrong? 关于我在做什么错的任何线索?

CSS: CSS:

div.nav-home {
margin-top: 10px;
margin-bottom: 0px;
margin-left: 130px;
Margin-right: -60px;
background-position: right top;
background-repeat: no-repeat;
width: 75px;
height: 64px;
}
#home {
background-image: url('img/home.png');
}
#home:hover {
background-image: url('img/home_hover.png');
}

Index.shtml: Index.shtml:

<table width="1213" height="64" align="center" background="img/tablebg2.png">
<!--#include file="menubuttons.html" -->

menubuttons.html: menubuttons.html:

<tr>    
<td align="center" width="75">
    <a href="/index.shtml" title="HOME" ><div id="home" class="nav-home"></div></a>
</td>

<td align="center" width="86">
    <a href="/about.shtml" title="ABOUT" ><div id="about" class="nav-about"></div></a>
</td>

<td align="center" width="94">
    <a href="/gallery.shtml" title="GALLERY" ><div id="gallery" class="nav-gallery">
</div></a>
</td>   

<td align="center" width="63">
    <a href="/blog.shtml" title="BLOG" ><div id="blog" class="nav-blog"></div></a>
</td>   

<td align="center" width="85">
    <a href="/prints.shtml" title="PRINTS" ><div id="prints" class="nav-prints"> 
 </div></a>
</td>

<td align="center" width="103">
    <a href="/contact.shtml" title="CONTACT" ><div id="contact" class="nav-contact">
</div></a>
</td>   
</tr> 

FIXED: (maybe not properly?) 修正:(也许不正确吗?)

I have only been coding for 2 months and have a pretty good idea on how to write it out, but I don't know what everything means such as the DIV tag. 我只编写了2个月的代码,并且对如何写出一个很好的主意,但我不知道诸如DIV标签之类的一切含义。 I know I was searching on here last night and I assumed I was to put the div inside a TD. 我知道我昨晚在这里搜索,我以为是将div放入TD中。

I was able to fix everything by simply adding a few spacer.png's before the first button in between each set of buttons and after the last button. 通过在每组按钮之间的第一个按钮之前和最后一个按钮之后添加几个spacer.png,我能够解决所有问题。 This also fixed my spacing issues on the sides. 这也解决了我侧面的间距问题。

Thanks for the help. 谢谢您的帮助。 I simply am trying to find an easy way to make my buttons change on hover. 我只是想找到一种简单的方法来使鼠标悬停时更改按钮。 This method was the first I found last night on here and am now trying to perfect it.. well in my head at least. 这种方法是我昨晚在这里发现的第一个方法,现在正试图完善它。 I need to research on the unordered list a little because I have heard that that makes things more simple... 我需要对无序列表进行一些研究,因为我听说这会使事情变得更简单...

Here is the link(based off the back end of a site I recently finished) www.blackmarkettattoos.com/amysesco/index.shtml 这是链接(基于我最近完成的网站的后端)www.blackmarkettattoos.com/amysesco/index.shtml

I think the problem is the fact that you are using DIV, which is a container tag inside table's cell, and for both you apply style (to the DIV as class and to the TD as inline). 我认为问题在于您正在使用DIV,这是表单元格内的容器标记,并且两者都应用了样式(以类的形式应用于DIV,以内联的形式应用于TD)。

Generally, it is better to create menus with lists, but if you must use the code you provided, then try to remove width: 75px; 通常,最好使用列表创建菜单,但是如果必须使用提供的代码,则尝试删除宽度:75px; from the div.nav-home. 来自div.nav-home。

Check these two links for how to create CSS menus with lists: 检查这两个链接,以了解如何使用列表创建CSS菜单:

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

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