css - 制作垫片最干净的方法 [英] css - cleanest way to make spacer

查看:65
本文介绍了css - 制作垫片最干净的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i我会让我的页面更加css和xhtml兼容。

在我得到以下代码之前:

- -------------------

< p>第一个文字< / p>

< p>< ; img src =" spacer.gif"宽度= QUOT 1 QUOT;高度= QUOT; 80 QUOT; />< / p>

< p>第二个文字< / p>

---------------- -----


通过更改透明spacer.gif的值,我可以在我想要的页面上安排

的第二个文本。


有没有一个很好的方法用css做这个?

解决方案

Wilhelm Kutting写道:


我将使我的页面更加css和xhtml兼容。
在我得到以下代码之前:
------ ---------------
< p>第一个文字< / p>
< p>< img src =" spacer.gif"宽度= QUOT 1 QUOT;高度= QUOT; 80 QUOT; />< / p>
< p>第二个文字< / p>
---------------------

通过更改透明spacer.gif的值,我可以在我想要的页面上排列第二个文本。

有没有一个很好的方法来做到这一点用css?




是的,

< p>第一个文字< / p>

< p class =" second"> second text< / p>


并且在你的风格中(因此它适用于所有带有''秒的页面 -

class paragraph''):

p.second {margin-top:80px;}


-

Els
http://locusmeus.com/

Sonhos vem。 Sonhos v?o。 Orestoébritfeito。

- Renato Russo -


Els写道:

Wilhelm Kutting写道:


我将使我的页面更加css和xhtml兼容。
在我得到以下代码之前:
---------------------
< p>第一个文字< / p>
< p>< img src =" ; spacer.gif的"宽度= QUOT 1 QUOT;高度= QUOT; 80 QUOT; />< / p>
< p>第二个文字< / p>
---------------------

通过更改透明spacer.gif的值,我可以在我想要的页面上排列第二个文本。

有没有一个很好的方法来做到这一点用css?



是的,
< p>第一个文字< / p>
< p class =" second">第二个文字< / p>

并且在你的风格中(所以它适用于所有带有''second-
类段落''的页面):
p.second {margin- top:80px;}



这是上一段80px的保证金

我可以从页面顶部使用绝对保证金吗?


Wilhelm Kutting写道:

< p>第一个文字< / p>
< p class =" second"> second text< / p>

并且在你的风格中(所以它适用于所有带有
''二等段'的页面 ):
p.second {margin-top:80px;}


这是距离最后一段80px的边距
我可以使用页面顶部的绝对边距吗? / blockquote>


是的,但它不会被称为保证金。

p.second {position:absolute; top:80px}
将第二段设置为距离最近定位的父项的顶部80个像素。

含义:如果段落在另一个div中也有

位置:绝对位置:相对位置,80位像素是从该div顶部计算的



警告!!:你甚至不用考虑使用职位属性

,直到你真正理解CSS为止。

设置第二个只是一个小小的劣势
页面顶部
段到80px:如果

第一段更高,因为有人调整了字体 -

大小会怎么样?


-

Els
http://locusmeus.com/

Sonhos vem。 Sonhos v?o。 Orestoébritfeito。

- Renato Russo -


Hi,
i am going to make my pages more css and xhtml compatible.
Before i got athe following code:
---------------------
<p>first text</p>
<p><img src="spacer.gif" width="1" height="80" /></p>
<p>second text</p>
---------------------

By changing the value of the transparent spacer.gif i can arange the
second text on the page where i want it to.

Is there a good way to do this with css?

解决方案

Wilhelm Kutting wrote:

Hi,
i am going to make my pages more css and xhtml compatible.
Before i got athe following code:
---------------------
<p>first text</p>
<p><img src="spacer.gif" width="1" height="80" /></p>
<p>second text</p>
---------------------

By changing the value of the transparent spacer.gif i can
arange the second text on the page where i want it to.

Is there a good way to do this with css?



Yes,
<p>first text</p>
<p class="second">second text</p>

And in your styles (so it''ll work for all pages with a ''second-
class paragraph''):
p.second{margin-top:80px;}

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos v?o. O resto é imperfeito.
- Renato Russo -


Els wrote:

Wilhelm Kutting wrote:

Hi,
i am going to make my pages more css and xhtml compatible.
Before i got athe following code:
---------------------
<p>first text</p>
<p><img src="spacer.gif" width="1" height="80" /></p>
<p>second text</p>
---------------------

By changing the value of the transparent spacer.gif i can
arange the second text on the page where i want it to.

Is there a good way to do this with css?


Yes,
<p>first text</p>
<p class="second">second text</p>

And in your styles (so it''ll work for all pages with a ''second-
class paragraph''):
p.second{margin-top:80px;}


This is margin 80px from the last paragraph
Can i use absolute margin from top of page, too?


Wilhelm Kutting wrote:

<p>first text</p>
<p class="second">second text</p>

And in your styles (so it''ll work for all pages with a
''second- class paragraph''):
p.second{margin-top:80px;}


This is margin 80px from the last paragraph
Can i use absolute margin from top of page, too?



Yes, but it''s not called margin then.
p.second{position:absolute;top:80px}
will set the second paragraph exactly 80 pixels from the top of
the closest positioned parent.
Meaning: if the paragraphs are inside another div which also has
position:absolute, or position:relative, the 80 pixels are
calculated from the top of that div.

WARNING!!: don''t even think about using the position property
until you really understand CSS.
Just one small little tiny disadvantage of setting the second
paragraph to 80px from the top of the page: What happens if the
first paragraph is higher because someone adjusted the font-
size?

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos v?o. O resto é imperfeito.
- Renato Russo -


这篇关于css - 制作垫片最干净的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆