将相同的宽度应用于子div作为父div [英] Apply same width to child divs as parent div

查看:146
本文介绍了将相同的宽度应用于子div作为父div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div包含几个div。我改变了父div的宽度。但是因为div是父div的孩子,宽度正在增加。我写这样的css类。

i have one div which contains several divs. I changed the parent div width. But because of the divs which are children to the parent div, the width is increasing. i written the css class like this.

$('#s4-workspace').css({
    'width': '900px'
});

这里 s4-workspace
应用上述属性后,当我在IE中看到,宽度增加到1600px。我想把这个宽度应用到所有的子div。是否有任何方法在jquery中实现这样的功能?

Here s4-workspace is the parent div. After applying the above property and when I see in the IE, the width is increasing to 1600px. I want to apply this width to all the child divs. Is there any method to achieve such functionality in jquery?

我在共享点设计器中工作。

i am working in sharepoint designer.

推荐答案

您可以使用 width() jquery函数设置宽度,方法是使用 children() 功能。 / p>

You can use width() jquery function to set the width by getting children using children() function.

$('#s4-workspace').children().width($('#s4-workspace').width());

更好地处理它与样式表,而不是jquery / javascript。以百分比设置儿童的宽度可以做到,例如100%。

Its better to handle it with style sheet instead jquery/javascript. Setting width of children in percentage could do it, like 100%.

这篇关于将相同的宽度应用于子div作为父div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆