1

I have written in css file so that there is no gap at top. It works fine.

*{margin:0px;padding:0px;}

but i don't this to applied to particular page as i am getting the formatted text from a richtextbox control which is saved in database.

How to handle this? Is it valid to give 0.5 px in css?

4

2 回答 2

2

您可以在任何其他页面中使用 !important 属性覆盖它,或者在加载第一个 css 文件后重载初始定义。

我想您是在问如何在元素顶部留出空隙?您没有指定差距在什么之上。

您可以使用边距 1px 或尝试 em 值:0.5em 作为度量。

通常,我像这样使用 css:

html, body { margin:0; padding:0; } 
#wrapper * { margin:0; padding:0; }

这样,包装器中的所有内容都将具有 0 边距和 0 填充,但页面上的其他元素不会,除非它们位于包装器对象内。

另一种选择是以一种将被覆盖的方式声明您的 CSS:

对于这个答案,您的代码可能是基于其他评论的类似内容:

* { margin:0; padding:0; } 
#wrapper * { margin:15px; padding:0; }

那么包装器 ID 中的任何内容都会有不同的设置。

于 2013-03-29T22:46:20.183 回答
0

It's fine to have that at the very top of your css page.

CSS actually stands for Cascading Style Sheet and this is where that is really obvious.

If you put *{margin:0px;padding:0px;} at the top of your file, any rules that are defined later in your file will overwrite this rule. The lower the rule in the 'cascade' the later it gets applied to the document.

See the cascade spec for how order in css is applied.

于 2013-03-29T22:44:09.607 回答