css中 display属性和visibility的区别

 

display Property Values


ValueDescription
noneThe element will generate no box at all
blockThe element will generate a block box (a line break before and after the element)
inlineThe element will generate an inline box (no line break before or after the element). This is default
inline-blockThe element will generate a block box, laid out as an inline box
inline-tableThe element will generate an inline box (like <table>, with no line break before or after)
list-itemThe element will generate a block box, and an inline box for the list marker
run-inThe element will generate a block or inline box, depending on context
tableThe element will behave like a table (like <table>, with a line break before and after)
table-captionThe element will behave like a table caption (like <caption>)
table-cellThe element will behave like a table cell
table-columnThe element will behave like a table column
table-column-groupThe element will behave like a table column group (like <colgroup>)
table-footer-groupThe element will behave like a table footer row group
table-header-groupThe element will behave like a table header row group
table-rowThe element will behave like a table row
table-row-groupThe element will behave like a table row group
inheritSpecifies that the value of the display property should be inherited from the parent element

 

visibility Property Values


ValueDescription
visibleThe element is visible. This is default
hiddenThe element is invisible (but still takes up space)
collapseOnly for table elements. collapse removes a row or column, but it does not affect the table layout. The space taken up by the row or column will be available for other content.

If collapse is used on other elements, it renders as "hidden"

inheritSpecifies that the value of the visibility property should be inherited from the parent element

We can know from above:

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

and

display: none removes the element completely from the document. It does not take up any space, even though the HTML for it is still in the source code.

Notice: if the display property is not explicitly set, it defaults to the display type the element normally has.

You also can refer here to see how they look “Set visibility: hidden on the image” and “Set display: none on the image”. :)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值