gpt4 book ai didi

javascript - Jquery SlideDown 按钮点击

转载 作者:行者123 更新时间:2023-11-28 02:30:43 24 4
gpt4 key购买 nike

我希望有一个滑动(向下)切换,但希望面板沿着按钮的左边缘整齐排列。我不想对边距、位置、像素等进行硬编码,但希望向下滑动面板始终与(和相对)按钮(左下角)“相关”。

我错过了什么?

<!doctype html>
<head>
<script src='http://code.jquery.com/jquery-1.7.2.min.js'></script>

<style type="text/css">
.slideToggleBox{
float:left;
padding:8px;
margin:16px;
border:1px solid red;
width:200px;
height:50px;
background-color:blue;
color:white;
position:fixed;
left:-10.5px;
top:2.3%;
}
.clear{
clear:both;
}
</style>
</head>

<body>

<div class="clear">
<button id=slideToggle>slideToggle()</button>
<br/>
<div class="slideToggleBox">
slideToggle()
</div>
</div>

<script type="text/javascript">
$("#slideToggle").click(function () {
$('.slideToggleBox').slideToggle();
});
</script>
</body>
</html>

最佳答案

试试这个代码。添加了demo here

HTML

<div class="wrapper">
<button class=slideToggle>slideToggle()</button>
<div class="slideToggleBox">slideToggle()</div>
</div>
<div class="wrapper">
<button class=slideToggle>slideToggle()</button>
<div class="slideToggleBox">slideToggle()</div>
</div>

CSS

.wrapper{
float:left;
width:200px;
}
.slideToggleBox {
float:left;
border:1px solid red;
width:200px;
height:50px;
background-color:blue;
color:white;
margin-top: -1px;
margin-left:1px;
}

JS

$(".slideToggle").click(function () {
$(this).next().slideToggle();
});

关于javascript - Jquery SlideDown 按钮点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14224266/

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