HTML / CSS:将列表填充重置为默认值

时间:2022-12-06 20:26:50

I'm using *{margin:0; padding:0;} and this is the first time that it breaks me in something. List paddings and margins are 0 too, so the indentation is lost. and I would like to reset them to their original state, how is this possible?

我正在使用* {margin:0; padding:0;}这是第一次让我破坏某些东西。列表填充和边距也是0,因此缩进会丢失。我想将它们重置为原始状态,这怎么可能?

I've tried this with no success:

我试过这个没有成功:

ul,ol{ 
   margin :auto; /* This Works */
   padding:auto; /* This Not :( */
}

So how should I fix this?

那我该怎么办呢?

3 个解决方案

#1


6  

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

这样做的一个好方法是查看浏览器的默认样式表(您应该能够通过搜索找到如何执行此操作)。例如,您可以使用以下URL查看Firefox默认样式表:resource://gre/res/html.css

#2


5  

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..

没有办法恢复默认值,但更改'ol'或'ul'和'li'的填充它看起来很好。这对我有用..

ol{
    padding: 0 25px;
}
ol li{
    padding-left: 0px;
}

#3


-5  

If I understand the question correctly, you could try adding !important; as in the following:

如果我正确理解了这个问题,你可以尝试添加!important;如下所示:

ul, ol {
   margin : auto;
   padding: auto !important;
}

Normally, it overrides all earlier predefined values.

通常,它会覆盖所有早期预定义的值。

#1


6  

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

这样做的一个好方法是查看浏览器的默认样式表(您应该能够通过搜索找到如何执行此操作)。例如,您可以使用以下URL查看Firefox默认样式表:resource://gre/res/html.css

#2


5  

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..

没有办法恢复默认值,但更改'ol'或'ul'和'li'的填充它看起来很好。这对我有用..

ol{
    padding: 0 25px;
}
ol li{
    padding-left: 0px;
}

#3


-5  

If I understand the question correctly, you could try adding !important; as in the following:

如果我正确理解了这个问题,你可以尝试添加!important;如下所示:

ul, ol {
   margin : auto;
   padding: auto !important;
}

Normally, it overrides all earlier predefined values.

通常,它会覆盖所有早期预定义的值。