HTML / CSS:将列表填充重置为默认值
我正在使用 *{margin:0; padding:0;}
这是第一次让我崩溃。 列表填充和边距也为 0,因此缩进丢失。并且我想将它们重置为原始状态,这怎么可能?
我已经尝试过但没有成功:
ul,ol{
margin :auto; /* This Works */
padding:auto; /* This Not :( */
}
那么我应该如何解决这个问题?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
重置的目的是消除由于浏览器默认设置造成的变化。换句话说,没有明确的方法来“取消重置”,因为不同的浏览器可能有不同的默认值。
但是,您可以选择自己的默认值,我认为这就是您在这里尝试做的。
执行此操作的一个好方法是查看浏览器的默认样式表(您应该能够通过搜索找到如何执行此操作)。例如,您可以使用以下 URL 查看 Firefox 默认样式表:resource://gre/res/html.css
The point of a reset is to eliminate variations due to browser defaults. In other words, there is no definitive way to "unreset" because different browsers may have different defaults.
However, you can choose your own default values, and I think that's what you're trying to do here.
A good way to do this is to look at a browser's default stylesheet (you should be able to find how to do this by doing a search). For example, you can see the Firefox default stylesheet with this URL: resource://gre/res/html.css
无法恢复默认值,但更改“ol”或“ul”和“li”的填充看起来不错。这对我有用..
There is no way to restore default values, but changing padding of 'ol' or 'ul' and 'li' it will look fine. This works for me..
正如您所看到的,如果您使用下面的代码片段,列表
padding-left
的initial
值为0
。我的观点是关于你的陈述:,我试图说明这一点,@jdigital 在他的回答中所说的是 CSS 属性没有原始状态,所有这些属性都是取决于他们的浏览器实现,例如默认浏览器样式表。
As you can see if you play with the snippet below, the
initial
value for listpadding-left
is0
. My point is regarding your statement:what I'm trying to illustrate and what @jdigital was kind of saying in his answer is that there is no original state for CSS properties, all of them are dependent on their browser implementation, e.g. default browser stylesheets.
重置填充和边距时必须记住,例如
*{padding: 0;边距:0;}
。ul
标记有一些填充,如padding-inline-start: default_value;
。通过以下这些步骤,您可以摆脱这个
list-style-position: Outside;
问题:padding-inline-start
open 的默认值您的浏览器开发人员工具并选择您的 ul 标签。padding-inline-start
样式,其值是40px
。现在记下这个值。ul
的样式,例如ul{padding-inline-start: 40px}
希望这对您有用。
You have to keep in mind when you reset padding and margin such as
*{padding: 0; margin: 0;}
. Theul
tag have some padding aspadding-inline-start: default_value;
.The following these steps you can get rid of this
list-style-position: outside;
issue :padding-inline-start
open your browser developer tools and select your ul tag.ul
tag styles fromuser agent stylesheet
it will look like thispadding-inline-start
in my browser its value is40px
. Now note this value.ul
such asul{padding-inline-start: 40px}
Hope this will work for you.
revert
就是您正在寻找的内容。它基本上会恢复由您的样式表创建的任何样式,而不是用户代理/浏览器样式表。参考:
revert
is what you are looking for. It will basically revert any styles made BY YOUR STYLESHEET and not the user-agent/browser stylesheet.Reference:
如果我正确理解了这个问题,您可以尝试添加
!important;
,如下所示:通常,它会覆盖所有早期的预定义值。
If I understand the question correctly, you could try adding
!important;
as in the following:Normally, it overrides all earlier predefined values.