What does quot;*quot; mean in CSS?(“*是什么意思?在 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.
这篇关于“*"是什么意思?在 CSS 中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“*"是什么意思?在 CSS 中是什么意思?
- Fetch API 如何获取响应体? 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Flexslider 箭头未正确显示 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 失败的 Canvas 360 jquery 插件 2022-01-01
