gpt4 book ai didi

javascript - Jquery SlideDown 偶尔工作

转载 作者:太空宇宙 更新时间:2023-11-04 03:16:54 25 4
gpt4 key购买 nike

我使用谷歌浏览器,但 slideDown 无法正常工作。有时 div 下降,有时仍然关闭,我必须刷新页面并等待它决定 slideDown。这是代码:

HTML

<header>
<div class="container">
<img src="../themes/<?= GDR_THEME ?>/images/graphic/barratop.png" />
<div id="box_body" class="content mCustomScrollbar light" data-mcs-theme="minimal">
<div id="box_text" >
<form name="termini" action="core.register_1.php" method="post">
<?php include_once "../text/regolamento.html"; ?>
<p class="button">
<input id="check" src="../themes/<?= GDR_THEME ?>/images/graphic/accettoff.png"
type="image" onMouseOver="this.src='../themes/<?= GDR_THEME ?>/images/graphic/accetton.gif'"
onMouseOut="this.src='../themes/<?= GDR_THEME ?>/images/graphic/accettoff.png'" />
<input name="rego" value="ok" type="hidden" />
</p>
</form>
</div>
</div>
<img src="../themes/<?= GDR_THEME ?>/images/graphic/barradown.png" />
</div>

CSS

.container {
width: 600px;
position: relative;
margin-left: auto;
margin-right: auto;
margin-top: 50px;
}
#box_body {
width: 530px;
height: 460px;
position: relative;
text-align: justify;
overflow-y: hidden;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 10px;
margin-left: auto;
margin-right: auto;
display: none;
}
#box_text {
position: relative;
float: left;
}
.button {
position: relative;
text-align: center;
}

JavaScript

$(document).ready(function(){
$("#box_body").slideDown(2500);
});

有时滑下来有时不...我的链接:http://khchapterzero.altervista.org/core/core.register_0.php

最佳答案

slideDown()确实工作得很好。问题是,您的脚本在 DOM 索引中的位置高于样式表:

<script src='../themes/custom/js/jquery.min.js'></script> 
<script src='../themes/custom/js/jquery.main.js'></script>
<script src='../themes/custom/js/jquery.scrollbar.js'></script>
<script src='../themes/custom/js/jquery.register_0.js'></script>
<link rel='icon' href='../themes/custom/images/engine/icon.png' type='image/x-icon' />
<link rel='stylesheet' type='text/css' href='../themes/custom/css/main.css' />
<link rel='stylesheet' type='text/css' href='../themes/custom/css/register_0.css' />
<link rel='stylesheet' href='../themes/custom/css/Scrollbar.css' />

这是您的 CSS 的一部分,有时 保留您的 #box_body隐藏:

#box_body {
...
display: none;
}

你的 display: none; CSS 样式有时应用于元素之后 slideDown();因为您的样式表文件有时在脚本文件之后加载。

好的做法是将 CSS 样式表放在 <head> 中关闭前的标签和脚本 </body>标签。

关于javascript - Jquery SlideDown 偶尔工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28546358/

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