“*"?在 CSS ?
问题说明
我一直在查看 Facebook 和 Youtube 等许多网站的 CSS 文件.
I have been looking at the CSS files for many websites like Facebook and Youtube.
在几乎所有的代码中,我都看到了这段代码:
In almost all of them I see this code:
* {
margin: 0;
padding: 0;
}
这很奇怪,因为在 chrome web 开发人员工具中删除该块不会影响页面的布局.
It is odd, as removing that block in chrome web developer tools doesn't affect the layout of the page.
这段代码是什么意思,什么时候使用,为什么使用?
What does this code mean, and when is it used and why?
正确答案
这是一种称为 CSS 重置的常用技术.不同的浏览器使用不同的默认边距,导致站点看起来不同的边距.*
表示所有元素"(一个 通用选择器),所以我们设置所有元素都具有零边距和零填充,从而使它们在所有浏览器中看起来都一样.
This is a common technique called a CSS reset. Different browsers use different default margins, causing sites to look different by margins. The *
means "all elements" (a universal selector), so we are setting all elements to have zero margins, and zero padding, thus making them look the same in all browsers.
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tangibgkf
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20