在< body>上设置CSS网格元件? [英] Set CSS Grid on <body> element?

查看:64
本文介绍了在< body>上设置CSS网格元件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在< body> 元素上声明网格吗?

Can a grid be declared on the <body> element?

我担心的是,使用包装器< div> 可能会留下一些不需要的填充/边距

My concern is that using a wrapper <div> can leave some unwanted padding / margins if you want the content to be flush with edges of the browser.

推荐答案

只需添加通用选择器(*)应用于CSS,这会将任何规则应用于页面上的每个元素。如果任何元素需要它们,则可以在这些元素本身上添加边距或填充。当您不太清楚是什么原因造成的时,这有助于消除间距。

Just add the universal selector (*) to your CSS, this will apply any rule to every element on the page. If any elements need them you can then add margins or padding to those elements themselves. This helps get rid of spacing when you can't quite tell what is causing it.

  * {
        margin:0;
        padding:0;
    }

这篇关于在&lt; body&gt;上设置CSS网格元件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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