Javascript 将鼠标悬停在div content上以显示新的div内容 加仑 帖子

Javascript 将鼠标悬停在div content上以显示新的div内容 加仑 帖子,javascript,jquery,css,hover,Javascript,Jquery,Css,Hover,我希望能够在div“trivlimp”上方悬停,以显示div“imp”位于“trivlimp”的正上方;将第一个div隐藏在div“imp”下面。我试着这样做:悬停,但完全失败了,结果只是让自己更加沮丧。我并不反对使用Jquery,但我想完全通过css来实现这一点;但是如果使用jquery更容易,我会使用它。我会使用jquery处理悬停状态。我也有点不明白这个问题。因此,我将您的代码放入JSFIDLE,并按照您所要查找的内容编写了我认为合适的代码。我使用了jQuery的mouseover/mou

我希望能够在div“trivlimp”上方悬停,以显示div“imp”位于“trivlimp”的正上方;将第一个div隐藏在div“imp”下面。我试着这样做:悬停,但完全失败了,结果只是让自己更加沮丧。我并不反对使用Jquery,但我想完全通过css来实现这一点;但是如果使用jquery更容易,我会使用它。

我会使用jquery处理悬停状态。我也有点不明白这个问题。因此,我将您的代码放入JSFIDLE,并按照您所要查找的内容编写了我认为合适的代码。我使用了jQuery的mouseover/mouseout:

<center>
    <div class="trivlimp">
        <center><div class="lyrics"><!-- |field_1| --></div></center>
    </div>

    <div class="imp">
        <div class="trgls"><!-- |points| --> Gallons</div><br>
        <div class="trals"><!== |field_2| --></div><br>
        <div class="trpc"><!-- |posts| --> posts</div><br>
        <div class="trttr"><!-- |field_3| --></div><br>
    </div>
</center>
​http://jsfiddle.net/arsCr/

执行以下操作: html:

​ jquery:

html代码

$(function() {
    $('.trivlimp').hover(function() {
        $('.imp').show();
    }, function() {
        $('.imp').hide();
    });
});​
jquery

.trivlimp {     background-color:#FF0000;
    width: 260px;
    height: 400px;
    text-align: center;
    position: absolute; }
.imp {     width: 260px;
    height: 400px;
    background-color:#676767;
    display: none;
    position: absolute;
    top: 0; }

.lyrics {
    margin-top: 50%;
    background-color: #CC0066;
    width: 180px;
    padding: 5px;
    height: 130px
    overflow: auto;
    text-align: justify;
    text-transform: uppercase;
    font-family: Georgia;
    font-style: italic;
    font-size: 10px;
    line-height: 10px;
}

.trgls {
    width: 190px;
    padding-top: 5px;
    padding-bottom: 5px;
    text-align: center;
    float: right;
    margin-right: 35px;
    background-color:#6666FF;
    text-transform: uppercase;
}

.trals {
    width: 170px;
    padding-top: 5px;
    padding-bottom: 5px;
    text-align: center;
    float: right;
    margin-right: 35px;
    background-color: #00FF00;
    text-transform: uppercase;
}

.trpc {
    width: 150px;
    padding-top: 5px;
    padding-bottom: 5px;
    text-align: center;
    float: right;
    margin-right: 35px;
    background-color: #FFCC00;
    text-transform: uppercase;
}

.trttr {
    width: 130px;
    padding-top: 5px;
    padding-bottom: 5px;
    text-align: center;
    float: right;
    margin-right: 35px;
    background-color: #009900;
    text-transform: uppercase;
}

我不太明白你的问题,但你可以使用以下方法:

$(function(){
$('.trivlimp').hover(function() {
    $('.imp').show();
},
function() {
    $('.imp').hide();
});
});

我很难理解你的问题。您能否更详细地指定在“正常”状态和悬停状态下哪个元素可以悬停,文档的哪些部分应该可见或不可见?在正常状态下,我希望div“imp”被隐藏,然后在div“trivlimp”的内容悬停时显示,div内容为“imp”隐藏div“trivlimp”的内容。有点像当你悬停在一个图像上,显示一个新的图像,但这一次的内容?它似乎在该网站上的工作,但当我把我自己的css和宽度;它不工作,悬停时div“trivlimp”不显示div“imp”。(这是在我的网站上)如果我提供我的css会有帮助吗?用你的HTML和css创建一个JSFIDLE(不添加jQuery)。发回来,我来看看。我想我做对了,我加入了所有用于此的css和html。
$(function() {
    $('.trivlimp').hover(function() {
        $('.imp').show();
    }, function() {
        $('.imp').hide();
    });
});​
<center>
<div class="trivlimp">
    <center><div class="lyrics"> |field_1| </div></center>
</div>

<div class="imp">
    <div class="trgls"> |points|  Gallons</div><br>
    <div class="trals">|field_2| </div><br>
    <div class="trpc"> |posts|  posts</div><br>
    <div class="trttr">|field_3|</div><br>
</div>
.trivlimp {     background-color:#FF0000;
    width: 260px;
    height: 400px;
    text-align: center;
    position: absolute; }
.imp {     width: 260px;
    height: 400px;
    background-color:#676767;
    display: none;
    position: absolute;
    top: 0; }

.lyrics {
    margin-top: 50%;
    background-color: #CC0066;
    width: 180px;
    padding: 5px;
    height: 130px
    overflow: auto;
    text-align: justify;
    text-transform: uppercase;
    font-family: Georgia;
    font-style: italic;
    font-size: 10px;
    line-height: 10px;
}

.trgls {
    width: 190px;
    padding-top: 5px;
    padding-bottom: 5px;
    text-align: center;
    float: right;
    margin-right: 35px;
    background-color:#6666FF;
    text-transform: uppercase;
}

.trals {
    width: 170px;
    padding-top: 5px;
    padding-bottom: 5px;
    text-align: center;
    float: right;
    margin-right: 35px;
    background-color: #00FF00;
    text-transform: uppercase;
}

.trpc {
    width: 150px;
    padding-top: 5px;
    padding-bottom: 5px;
    text-align: center;
    float: right;
    margin-right: 35px;
    background-color: #FFCC00;
    text-transform: uppercase;
}

.trttr {
    width: 130px;
    padding-top: 5px;
    padding-bottom: 5px;
    text-align: center;
    float: right;
    margin-right: 35px;
    background-color: #009900;
    text-transform: uppercase;
}
$(function(){
$('.trivlimp').hover(function() {
    $('.imp').show();
},
function() {
    $('.imp').hide();
});
});
.imp {
    display: none;
}

.trivlimp:hover + .imp {
    display: block;
}