html - 悬停状态不影响显示属性

标签 html css hover css-selectors

<分区>

我有以下 html 代码:

<div class="trial1">
He said all but the three newest reactors will be shut down by 2021, and the remainder a year later.Roettgen announced the agreement early on Monday morning after hour-long negotiations between the governing parties.Merkel in 2010 had pushed through to extend the lifespan of the country's 17 reactors with the last one scheduled to go offline in 2036, but she completely reversed her policy in the wake of Japan's nuclear disaster. She described the new move as a step that will make her country a pioneer in renewable energy.

<h1>This is h1</h1>

    <div class="trial2">
     this is something else what ever what ever
     </div>
</div>

我有以下 CSS:

.trial1
{
    position:relative;
}
.trial2
{
    display:none;
    position:absolute;
    z-index:20;
    top:1;
    left:1;
    width:30px;
    height:30px;
}
.trial1:hover>.trial2
{
    display:block;
}
.trial1:hover>h1
{
    color:red;
}

每当悬停 trial1 中的内容时,我都希望显示 trail2 中的内容。但不知何故,这不会发生。在同一元素悬停时更改 h1 颜色的类似过渡是否有效?我做错了什么?

最佳答案

缺少

.trial1:hover>.trial2

关于html - 悬停状态不影响显示属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6596455/

上一篇:html - 我怎样才能解决 Firefox 和 IE7 中明显的不一致问题?

下一篇:css - 在 xul 中设置菜单列表的样式

相关文章:

javascript - 在 div 中显示多个选择框和单选按钮值

javascript - Ember 无法将参数传递给操作

css - border-bottom 不出现在所有 TD 中,只出现在最后一个 TR 的 TD 中

javascript - 将鼠标悬停在元素上时显示子元素

jQuery:悬停时仅显示一个,而不是全部

javascript - 在 UpdateView Django 中保存 ImageField

android TagHandler 和 CSS

html - 如何使用 HTML 元素调整浏览器窗口的大小?

jquery - 仅当悬停在 li 中的 span 上时才显示下拉菜单

鼠标悬停时的 CSS1 Sprite 动画?