我有一个页面,当你悬停的时候就会出现。我想把这个更改为点击。不知怎么不起作用了。
联署材料:
$('section div').mouseenter(function(){
$(this).css('height', '80vh');
$(this).css('width', '100%');
$('#info').css('width', '100%');
});
$('section div').mouseleave(function(){
$(this).css('height', '2.5vh');
$(this).css('width', '100%');
$('#info').css('width', '100%');
});CSS:
iframe {
border: 0;
width: 100%;
height: 100%;
transition: 1s;
z-index: 2000;
}
#info {
position: fixed;
top: 0;
height: 80vh;
width: 100%;
transition: 1s;
z-index: 1;
}
section {
position: fixed;
bottom: 0;
width: 100%;
z-index: 2000;
}HTML:
<body>
<section></section>
</body>有时候,我的尝试完成了,但是只在iframe本身(空白)上,因此当iframe充满内容时什么都不会发生,也许这只是一个目标问题。
发布于 2016-12-11 11:13:44
我不太明白你的问题,你的click代码也不见了。据我所难以理解的是,您可以通过以下代码实现这一点:
$('section div').click(function() {
// This part is not really needed
if (this.state === undefined) {
this.state = 0;
}
// end of not needed part
if (this.state) {
$(this).css('height', '2.5vh');
$(this).css('width', '100%');
$('#info').css('width', '100%');
this.state = 0;
} else {
$(this).css('height', '80vh');
$(this).css('width', '100%');
$('#info').css('width', '100%');
this.state = 1;
}
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style>
section {
margin: 10px;
}
</style>
<div>
<section>
<div style="background-color: red; height: 2.5vh; width: 100%"></div>
</section>
<section>
<div style="background-color: green; height: 2.5vh; width: 100%"></div>
</section>
<section>
<div style="background-color: blue; height: 2.5vh; width: 100%"></div>
</section>
<section>
<div style="background-color: black; height: 2.5vh; width: 100%"></div>
</section>
</div>
https://stackoverflow.com/questions/41085262
复制相似问题