File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 45
45
1 . [ 为更好的移动体验,为表单元素设置字体大小] ( #为更好的移动体验为表单元素设置字体大小 )
46
46
1 . [ 使用指针事件来控制鼠标事件] ( #使用指针事件来控制鼠标事件 )
47
47
1 . [ 在用作间距的换行符上设置` display-none ` ] ( #在用作间距的换行符上设置display-none )
48
+ 1 . [ 使用 ` :empty ` 隐藏空 HTML 元素] ( #使用-empty-隐藏空-html-元素 )
48
49
49
50
50
51
### 使用CSS复位
@@ -240,7 +241,7 @@ body {
240
241
}
241
242
```
242
243
243
- ...還有CSS Grid:
244
+ ...还有CSS Grid:
244
245
245
246
``` css
246
247
body {
@@ -624,6 +625,20 @@ br + br {
624
625
625
626
<sup >[ 回目录] ( #目录 ) </sup >
626
627
628
+ ### 使用 ` :empty ` 隐藏空 HTML 元素
629
+
630
+ 如果你有空的 HTML 元素,即内容尚未由 CMS 设置或动态注入(例如:` <p class="error-message"></p> ` )并且它会在你的布局上创建不需要的空间,使用 ` :empty ` 伪类隐藏布局上的元素。
631
+
632
+ ``` css
633
+ :empty {
634
+ display : none ;
635
+ }
636
+ ```
637
+
638
+ 注意:请记住,带有空格的元素不会被视为空元素,例如 ` <p class="error-message"> </p> ` 。
639
+
640
+ <sup >[ 回目录] ( #目录 ) </sup >
641
+
627
642
628
643
### 支持情况
629
644
You can’t perform that action at this time.
0 commit comments