CSS:no当显示设置为none时的DIV宽度 [英] CSS: no DIV width when display set to none

查看:200
本文介绍了CSS:no当显示设置为none时的DIV宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行一个下拉窗口小部件。扩展的菜单设置为与父级(使用jQuery)相同的宽度。

I'm on the process of making a dropdown widget. The menu the expands down is set to the same width as the parent (using jQuery).

小部件按预期工作,直到将其放置在DIV初始显示设置为none的容器。当显示此容器时,根据jQuery的所有下拉宽度为零...
如果容器默认显示,所有工作。

The widget is working as expected, until however, you place it inside a DIV container with inital display set to none. When this container is shown, all the dropdown width's according to jQuery are zero... If the container is shown by default, all works.

希望我的小提琴会更好地说明我的意思: http://jsfiddle.net/ruFzR/
在结果窗格;顶部下拉是在容器外面,底部在里面。除了一些明显的造型问题,宽度不会扩大。

Hopefully my fiddle will better illustrate what I mean: http://jsfiddle.net/ruFzR/ On the results pane; the top dropdown is outside of the container, the bottom inside it. Besides some obvious styling issues, the width is not expanding.

推荐答案

您可以避免由 display:none; ,使用 visibility:hidden; 。使用 visibility:visible; 以使其可见。

You can avoid the width issue caused by display: none; by using visibility: hidden; instead. Use visibility: visible; to make it visible.

元素保留在您的内容流。),而它只是看不见。

The element stays within your content flow (same size, etc.) while it's simply invisible.

这篇关于CSS:no当显示设置为none时的DIV宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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