在.div中设置TEXT ONLY页边距/填充 [英] Setting TEXT ONLY margins/padding in a .div
问题描述
现在我正在使用它:
--------------------------- ---------------------------------
.div0 {
background-image:url(http://www.rubnip.com/Pictures/topback.gif);
background-position:center center;
background-重复:不重复;
background-attachent:fixed;
background-color:black;颜色:FFFFFF;
border:0px solid; border-color:grey;
padding-left:10px; padding-right:10px;
padding-top:10px; padding-bottom:10px;
宽度:800px;高度:250像素;溢出:无;
位置:绝对;的z-index:2;左:50%;顶部:0%;
margin-left:-400px;边距:150像素; text-align:center;
visibility:visible;}
----------------------- ---------------------------------------
唯一的问题是,当我在分隔符中使用该填充设置时,它也会移动我的背景图像。我只想设置一个仅影响分隔符内文本的边距或填充,而不是背景图像。怎么做呢?
-------------------------------- -------------------------------
< div class =" bbzContainer">
< div class =" div0">
< font size = 1>测试< / font>
< / div>
---------------------------------------- -----------------------
或许我可以在字体标签中放一些会影响的东西只有文字?
任何帮助表示赞赏。 :)
Right now I am currently using this:
------------------------------------------------------------
.div0 {
background-image:url(http://www.rubnip.com/Pictures/topback.gif);
background-position:center center;
background-repeat:no-repeat;
background-attachent:fixed;
background-color:black; color:FFFFFF;
border:0px solid; border-color:grey;
padding-left:10px; padding-right:10px;
padding-top:10px; padding-bottom:10px;
width:800px; height:250px; overflow:none;
position:absolute; z-index:2; left:50%; top:0%;
margin-left:-400px; margin-top:150px; text-align:center;
visibility:visible;}
--------------------------------------------------------------
The only problem is, when I use that padding setting within the divider, it also moves my background image. I just want to set a margin or padding that affects the text within the divider only, not the background image. How would this be done?
---------------------------------------------------------------
<div class="bbzContainer">
<div class="div0">
<font size=1>Test</font>
</div>
---------------------------------------------------------------
Or maybe I can put something in there in the font tag that will affect only the text?
Any help is appreciated. :)
推荐答案
您正在将边距/填充应用于div,这就是背景移动的原因。您没有对文本本身应用任何定位,并且无论如何字体都无法定位。 < font>标签也走了做鸟的方式。不要使用它。
相反,要么将标记括在一个段落中,< p>标记,或者,如果它是标题,则称之为:< h1>,< h2>等等。然后你就可以把它放在你的CSS中了:
h1 {margin:20px}
然后你将定位应用于文本和不是div。
You are applying the margin/padding to the div so that''s why the background moves. You don''t have any positioning applied to the text itself and font is not positionable anyway. The <font> tag also went the way of the do-do bird. Do not use it.
Instead, either enclose your tag in a paragraph, <p> tag, or, if it''s a heading, call it that: <h1>, <h2> and so on. Then you can position it in your css like so:
h1{margin:20px}
Then you are applying positioning to the text and not the div.
您正在将边距/填充应用于div,这就是背景移动的原因。您没有对文本本身应用任何定位,并且无论如何字体都无法定位。 < font>标签也走了做鸟的方式。不要使用它。
相反,要么将标记括在一个段落中,< p>标记,或者,如果它是标题,则称之为:< h1>,< h2>等等。然后你就可以把它放在你的CSS中了:
h1 {margin:20px}
然后你将定位应用于文本和不是div。
You are applying the margin/padding to the div so that''s why the background moves. You don''t have any positioning applied to the text itself and font is not positionable anyway. The <font> tag also went the way of the do-do bird. Do not use it.
Instead, either enclose your tag in a paragraph, <p> tag, or, if it''s a heading, call it that: <h1>, <h2> and so on. Then you can position it in your css like so:
h1{margin:20px}
Then you are applying positioning to the text and not the div.
确定我在哪里放置h1 {margin:20px}?我的样式表中的任何地方?或者特别是某个地方?
感谢您在< font>上的提示标签也是。我已经离开了网络编码循环,我正在学习CSS。
所以我将在h1中定义我的所有文本属性{余量:20像素}"我和< h1>之间的等级和任何东西< p为H. < H2>标签将根据每个类的定义方式(分别为h1,p和h2)进行调整吗?
P.S.我需要在h1 {margin:20px}中加分号吗?在20px之后?
OK where exactly do I put the "h1{margin:20px}"? Anywhere in my style sheet? Or is there some place in particular?
Thanks for the heads up on the <font> tag too. I''ve kinda been out of the web coding loop and I''m learning CSS at the moment.
So I''ll define all my text properties in the "h1{margin:20px}" class and whatever I put between my <h1> <p> <h2> tags will be adjusted according to how the each class is defined (h1, p and h2 each respectively) correct?
P.S. Do I need a semicolon in "h1{margin:20px}" after the 20px?
确定我在哪里放置h1 {margin:20px}?我的样式表中的任何地方?或者特别是某个地方?
感谢您在< font>上的提示标签也是。我已经离开了网络编码循环,我正在学习CSS。
所以我将在h1中定义我的所有文本属性{余量:20像素}"我和< h1>之间的等级和任何东西< p为H. < H2>标签将根据每个类的定义方式(分别为h1,p和h2)进行调整吗?
P.S.我需要在h1 {margin:20px}中加分号吗? 20px之后?
OK where exactly do I put the "h1{margin:20px}"? Anywhere in my style sheet? Or is there some place in particular?
Thanks for the heads up on the <font> tag too. I''ve kinda been out of the web coding loop and I''m learning CSS at the moment.
So I''ll define all my text properties in the "h1{margin:20px}" class and whatever I put between my <h1> <p> <h2> tags will be adjusted according to how the each class is defined (h1, p and h2 each respectively) correct?
P.S. Do I need a semicolon in "h1{margin:20px}" after the 20px?
这是我尝试的,它没有工作大声笑。我认为我做错了:
p {
magrin-left:10px
margin-right:10px
margin-top:10px
margin-bottom:10px
font-size:1
font-color:FFFFFF}
h1 {
magrin-left:10px
保证金权利:10px
保证金 - 上:10px
保证金底部:10px
字体大小:3
字体颜色:CCCC99}
>
h2 {
magrin-left:10px
margin-right:10px
margin-top:10px
margin-bottom:10px
font-size:2
font-color:CCCC99}
Here is what I tried, it didn''t work lol. I assume I am doing it wrong:
p {
magrin-left:10px
margin-right:10px
margin-top:10px
margin-bottom:10px
font-size:1
font-color:FFFFFF}
h1 {
magrin-left:10px
margin-right:10px
margin-top:10px
margin-bottom:10px
font-size:3
font-color:CCCC99}
h2 {
magrin-left:10px
margin-right:10px
margin-top:10px
margin-bottom:10px
font-size:2
font-color:CCCC99}
这篇关于在.div中设置TEXT ONLY页边距/填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!