gpt4 book ai didi

jQuery 动画压缩内容?

转载 作者:行者123 更新时间:2023-11-28 10:56:51 26 4
gpt4 key购买 nike

简单的问题有很多细微差别,因为我正在学习 jQuery...

HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery-1.6.2.js"></script>
<script type="text/javascript" src="script.js"></script>

</head>
<body>
<div id="container">
<div id="header">
</div>
<div id="body">
<div id="flip_body">
<div id="top_body">
<div id="top_body_left">
<p id="text">This will be a really long string to test if things get squished</p>
<div id="left_test" class="test">
</div>
<div id="right_test" class="test">
</div>
</div>
<div id="top_body_right">
</div>
</div>
<div id="bottom_body">
</div>
</div>
<div id="flip">
<p>Flip</p>
</div>
</div>
<div id="footer">
</div>
</div>
</body>
<html>

CSS:

#container
{
width:1000px;
height:600px;
background-color:red;
}
#header
{
width:100%;
height:15%;
background-color:orange;
}
#body
{
width:100%;
height:70%;
background-color:yellow;
}
#top_body
{
width:100%;
height:100%;
background-color:red;

}
#bottom_body
{
width:100%;
height:100%;
background-color:pink;
display:none;

}
#flip_body
{
width:90%;
height:100%;
float:left;
position:relative;
}
#flip
{
width:10%;
height:100%;
float:left;
background-color:green;
}
#top_body_left
{
height:100%;
float:left;
background-color:teal;
position:absolute;
left:0px;
top:0px;
bottom: 0px;
width: 250px;
}
#top_body_right
{
height:100%;
float:left;
background-color:black;
position:absolute;
left:300px;
top:0px;
bottom: 0px;
width: 200px;
}
#text
{
overflow:hidden;
}
#left_test
{
background-color:orange;

}
#right_test
{
background-color:red;
width:150px;
}
.test
{
width:100px;
height:100px;
float:left;
}
#footer
{
width:100%;
height:15%;
background-color:blue;
}

jQuery:

$(document).ready(function(){  
$("#flip").data("open", false);

$("#flip").click(function() {
// slide to the right
if ($(this).data("open") == false) {
$("#top_body_left").animate({width:'toggle'},500);
$("#top_body_right").animate({width: '+=100', duration:500});

$(this).data("open", true);
}
// slide to the left
else {
$("#top_body_left").animate({width:'toggle'},500);
$("#top_body_right").animate({width:'-=100'},500);

$(this).data("open", false);
}
});

});

如何防止 #top_body_left div 更改子项的排列(#left_test#right_test)?有没有一种方法可以在不移动 float 或不包裹任何内容的情况下进行切换?我阅读了有关使用 css 剪辑的信息,但我不确定这是否是我需要的。

最佳答案

我认为您需要将内容封装在另一个容器中并将 overflow:hidden 添加到内部容器(这是针对您要压缩的每个 block ),然后压缩外部容器。

关于jQuery 动画压缩内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6950426/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com