Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用jQuery的div的高度?_Php_Jquery_Animation_Jquery Animate_Sliding - Fatal编程技术网

Php 使用jQuery的div的高度?

Php 使用jQuery的div的高度?,php,jquery,animation,jquery-animate,sliding,Php,Jquery,Animation,Jquery Animate,Sliding,我已经创建了一个公文包图像库,但无法使标题正常工作。。。我在用:(我在用第二个) 唯一的问题是我的标题大小不同,因此我尝试使用以下代码: $('.boxgrid.caption').hover(function () { var $height = $("#description-text", this).height(); $(".cover", this).stop().animate({ top: '375' - $height }, {

我已经创建了一个公文包图像库,但无法使标题正常工作。。。我在用:(我在用第二个)

唯一的问题是我的标题大小不同,因此我尝试使用以下代码:

$('.boxgrid.caption').hover(function () {
    var $height = $("#description-text", this).height();
    $(".cover", this).stop().animate({
        top: '375' - $height
    }, {
        queue: false,
        duration: 160
    });
}, function () {
    $(".cover", this).stop().animate({
        top: '365px'
    }, {
        queue: false,
        duration: 160
    });
});
但是由于某种原因,
$height
的输出代码是395,而它应该是150或者沿着这些线的某个地方

请帮忙

谢谢 Ben

$(“#描述文本”,这个)
很奇怪

$(“#描述文本”)
应该足够了,前提是代码中只有一个元素具有此ID。如果没有,那么这就是问题所在。

尝试使用outerHeight(),因为它在框中包含填充和边框

更改第二行

var $height = $("#description-text").height();
我已经解决了答案(有点)我只是把文本框改到了一边,我要让它从一边滑进去

谢谢
Ben

你真的需要提供更多的上下文,或者提供一把小提琴。当你给我们的选择器似乎是无中生有的时候,很难理解你在说什么。什么是“描述文字”?您是否确保您的
描述文字
div实际高度为150?我通常通过更改
style=“background color:Fuchsia;”“
或其他颜色来测试公文包选项卡下的div实际有多大,但只有在CSS定义中设置了高度时才会返回值。按照我的理解,高度取决于元素的内容。因此,swenflea将使用DOM高度,这要求他使用
.height()