HTML部分和div固定大小

时间:2015-10-03 08:02:49

标签: javascript jquery html css google-chrome-extension

我试图将某个区域内div的高度修改为100px。然而,无论我尝试什么,高度都会恢复到“自动”状态。并根据div中的内容量重新调整大小。

这是HTML代码:

<section id="social" class="tab-content active">
    <div id = "socialDiv"></div>
</section>

这是我到目前为止所尝试的内容

CSS:

social{height:100px; line-height:20px;overflow:hidden;}
.socialDiv{height:100px !important; line-height:20px;overflow:hidden;}

jQuery:

$('.socialDiv').css({'height':100+'px'});
$('.socialDiv').height( 100 );

不幸的是,这些都不起作用。我对此感到非常感激。

PS。我不知道这是否重要,但这是Chrome扩展程序的一部分,此部分是执行期间显示的弹出窗口的一部分。

1 个答案:

答案 0 :(得分:1)

您将#class)与.tab-content)混合

您的课程为social但您正在尝试更改js和css上的ID $('.tab-content').css({'height':100+'px'}); $('.tab-content').height( 100 );

尝试:

[root@Z ~]# echo \n
n
[root@Z ~]# echo "\n"
\n
[root@Z ~]# echo '\n'
\n