2011-09-09 40 views
15

简单..我遇到了语法错误。 $('#container').css('min-height', '360');没有设置规则,但$('#container').css('height', '360');呢。jQuery css min-height

帮助?

+0

一个类似的最小高度的问题:http://stackoverflow.com/问题/ 2750892/jquery-set-min-height-of-div –

回答

33

首先尝试:

$('#container').css('min-height', '360px'); 

否则尽量

$('#container').attr('style','min-height:360px;other-styles'); 
2

使用

$('#container').css('min-height', '360px'); 
+0

该属性实际上是最小高度 –

+0

@Paolo - 谢谢,我打算回来并删除之后 - 我必须包括它,因为最低字符要求编辑 –

+0

@Zachary欢迎:) –

2

了这个问题传递对象字面当寻找jQuery.css

使用jQuery 2我可以这样做:

$(selector).css({minHeight:"20px"}); 

现在我可以一次传递了一堆东西:

$(selector).css({ 
    minHeight:"20px", 
    minWidth:"20px", 
    backgroundColor:"yellow", 
});