你如何创建一个不创建换行符或水平空间的隐藏div? [英] How do you create a hidden div that doesn't create a line break or horizontal space?

查看:106
本文介绍了你如何创建一个不创建换行符或水平空间的隐藏div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果我有这个:

 < div id =divCheckboxstyle =visibility:hidden> 

我没有看到复选框,但它仍然创建一个新行。



如果我有这样的话:

 < div id =divCheckboxstyle = visibility:hidden; display:inline;> 

不再创建新行,但占用了屏幕上的水平空间。



有没有办法让一个隐藏的div不占用空间(垂直或水平)?

解决方案

使用 display:none;

 < div id =divCheckboxstyle =display:none;> 




  • visibility:hidden 隐藏元素,但它仍占用布局空间。



  • ul>

    I want to have a hidden checkbox that doesn't take up any space on the screen.

    If I have this:

    <div id="divCheckbox" style="visibility: hidden">
    

    I don't see the checkbox, but it still creates a new line.

    If I have this:

    <div id="divCheckbox" style="visibility: hidden; display:inline;">
    

    it no longer creates a new line, but it takes up horizontal space on the screen.

    Is there a way to have a hidden div that takes up no room (vertical or horizontal?

    解决方案

    Use display:none;

    <div id="divCheckbox" style="display: none;">
    

    • visibility: hidden hides the element, but it still takes up space in the layout.

    • display: none removes the element completely from the document, it doesn't take up any space.

    这篇关于你如何创建一个不创建换行符或水平空间的隐藏div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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