CSS对A&LT悬停效果; TD>不正常热锅如果&所述; TD>有多个< D​​IV> S里面 [英] CSS on hover effect on a <td> does not wok properly if <td> has multiple <div>s inside it

查看:205
本文介绍了CSS对A&LT悬停效果; TD>不正常热锅如果&所述; TD>有多个< D​​IV> S里面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有里面多个div表列以适应一个图标,标题和描述文字。此外,在鼠标悬停时,我需要提供一个亮点/叠加效应,突出所有列,包括div的图像,标题和描述文字。

下面是HTML


 < TD>
  < D​​IV的风格=显示:inline-block的;边界:1px的红色实心>左< / DIV>
   < D​​IV的风格=显示:inline-block的>
   < D​​IV的风格=显示:inline-block的;边界:1px的固体蓝>左上方< / DIV>
   < D​​IV的风格=显示:inline-block的;边界:1px的纯绿色>右上方< / DIV>
   < D​​IV>底部< / DIV>
  < / DIV>
< / TD>


当我用一个简单的CSS作用改变,如下列的背景,效果显示出来仅在个别的div而不是整个表列。我想,如果有任何的div中取得了鼠标,所有列应被突出显示。

CSS code

  #MyTable TD:悬停{
背景:#CCCCCC;
}


解决方案

您面前一个额外的空间:悬停:尝试用

  #MyTable TD:悬停{
   背景色:#CCC;
}

I have a table column with multiple divs inside it to fit in an icon, title and description text. Also, on mouse over, I need to provide a highlight /overlay effect that highlights all of the column including the divs image, title and description text.

Here is the HTML

<td>
  <div style="display:inline-block; border:1px solid red">left</div>
   <div style="display:inline-block">
   <div style="display:inline-block; border:1px solid blue">top left</div>
   <div style="display:inline-block; border:1px solid green">top right</div>
   <div>bottom </div>  
  </div>
</td>

When I use a simple CSS effect to change the background of the column as below, the effect shows up only on individual divs but not the entire table column. I want that if any of the divs get a mouse over, all of the column should be highlighted.

CSS code

#MyTable td :hover {
background: #cccccc;
}

解决方案

you have an extra space before :hover : try with

#MyTable td:hover { 
   background-color: #ccc;
}

这篇关于CSS对A&LT悬停效果; TD&GT;不正常热锅如果&所述; TD&GT;有多个&LT; D​​IV&GT; S里面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆