473,671 Members | 2,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting TEXT ONLY margins/padding in a .div

10 New Member
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:absolu te; z-index:2; left:50%; top:0%;
margin-left:-400px; margin-top:150px; text-align:center;
visibility:visi ble;}
--------------------------------------------------------------

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="bbzConta iner">
<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. :)
Nov 30 '06 #1
12 22269
drhowarddrfine
7,435 Recognized Expert Expert
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.
Nov 30 '06 #2
mi0sis
10 New Member
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.
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?
Nov 30 '06 #3
mi0sis
10 New Member
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?
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}
Nov 30 '06 #4
mi0sis
10 New Member
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}
Whoops spelled on of the "margins" wrong. X_X
Nov 30 '06 #5
mi0sis
10 New Member
Oh yeah, not to ask 5000000 questions but, is there anyway I can make the scrollbars affected by the margin? I.E. Say the divider is 400px in height, I have margins on top and bottom set to 20, the scrollbars only scroll between pixels 21 and 379.

Thanks again for all the help. :D
Nov 30 '06 #6
mi0sis
10 New Member
Oh yeah, not to ask 5000000 questions but, is there anyway I can make the scrollbars affected by the margin? I.E. Say the divider is 400px in height, I have margins on top and bottom set to 20, the scrollbars only scroll between pixels 21 and 379.

Thanks again for all the help. :D
OK, I fixed all the margins and got them working. :)

My question still stands about the scrollbars though, any way to get them to obey margins?

Thanks again.
Nov 30 '06 #7
AricC
1,892 Recognized Expert Top Contributor
OK, I fixed all the margins and got them working. :)

My question still stands about the scrollbars though, any way to get them to obey margins?

Thanks again.
Jumping in late on this but what do you mean by scroll bars obey the margins?
Nov 30 '06 #8
drhowarddrfine
7,435 Recognized Expert Expert
Do I need a semicolon in "h1{margin:20px }" after the 20px?
Only to seperate other attributes of the same element, so, no.
font-size:1
font-color:FFFFFF}
font-size requires a unit type, such as ems or px. font-color requires a # before the number, ie, #ffffff. Case matters in CSS so use lower case.
http://www.w3.org/TR/CSS21/fonts.html#prop def-font-size

CSS Full Property Table

I don't know what is meant by the scrollbars, too.
Nov 30 '06 #9
mi0sis
10 New Member
Only to seperate other attributes of the same element, so, no.
font-size requires a unit type, such as ems or px. font-color requires a # before the number, ie, #ffffff. Case matters in CSS so use lower case.
http://www.w3.org/TR/CSS21/fonts.html#prop def-font-size

CSS Full Property Table

I don't know what is meant by the scrollbars, too.
Thanks again for the help.

OK, let's see here how can I describe what I mean here about the scrollbars.

Well OK let's say I have this 400 x 400 divider. If I have text and images that exceeds that size it will cause an overflow. I currently have my overflow set to "auto" so that in turn will create a scrollbar within' the divider so you can see the text and images in the divider that have gone over the height and width specifications.

My problem is, the scrollbars span the entire length of the divider, I.E. they start at pixel 0 and go all the way to pixel 400. By doing this, when you scroll through the divider the text also goes all the way to pixel 0 and 400 when clipping off the divider. So is there a way I can set the scrollbar height to match the size 380 x 380 (Starting at pixel 21 and ending at pixel 379) so that the text doesn't go all the way to the very edge of the divider when it scrolls off?

Here is the site I am working on:

http://www.myspace.com/fullofstupidand lose

Note: Contains obscenities.

If you look at any of the dividers with scrollbars you can see I have a background image that is supposed to appear as a window for the text to sit in. When you scroll up or down though, the text overlaps that image and goes all the way to the edge of the divider.

I hope this helps to clarify. I think that's the best way I can describe it. Thanks much guys. :)
Nov 30 '06 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
8986
by: Mr. x | last post by:
Hello, Suppose I have a table like this : <table width = "580"> <tr align = "right" width = 760> <td id = "current_page_inner"> <font size="4" color="lightgreen" face="arial"><b><i> abc </i></b>
4
1971
by: Mike | last post by:
The following (C#) code snippet sets the text property of a label to null, then tests it for null, only to find out that is isn't. Can anyone explain why? Label1.Text = null; if (Label1.Text == null) { Label2.Text = "Is null"; } else { Label2.Text = "Is not null"; }
0
1771
by: John Dalberg | last post by:
I need to set IE's print left margin to a value smaller than the default 0.75 programmaticallly. I did some research and found some info about print templates on MSDN. However the info is too detailed and low level for my understanding. I also found an ActiveX product that costs $350/year. Any ideas or sample code on how to set the margins when a user prints in IE?
6
3545
by: one man army | last post by:
> <URL:http://developer.mozilla.org/en/docs/DOM:element.textContent> I tried setting the textContent on a trivial DIV text element. Querying the result with window.alert() shows that it worked. Yet the page does not change. Is there a clean way to update the text on the screen? d.write() d.close() causes a complete page redraw. In an application, we used to InvalRect() the affected area, or swap an offscreen buffer. ugly white...
1
1742
HansHenrik
by: HansHenrik | last post by:
Hi experts! I've made a CSS menu. {The menu contains: no images; !important} I would like to position my text close to the bottom in my list-items as in example 02 and 03. At the moment example 02 is the closest to what i want, but i can't do it without the padding and "overflow:hidden" commands.
4
1246
by: NEMA | last post by:
Hello everyone, i have a problem while setting the button text recently for my case, i would like to set the text of the button on the aspx page, i have write the code like below <asp:button id="btn_submit" text='<%# GetText("abc.xml","btn_text") %>' >
10
3084
by: maya | last post by:
hi, I'm having a problem w/bulleted lists.. as you know FF and IE do diff margins/spacing for these, so have to do stuff like /* IE: */ * html ul.headlines {margin-left:20px; margin-top:0px; } /* FF: */ htmlbody ul.headlines {margin-left:-20px; margin-top:0px; }
0
979
by: Alexnb | last post by:
I am writing a program in which there is a textbox and in it the program auto inputs a series of words, and definitions for each word. I want to make it formatted nicely to where the word is indented, and the definitions indented even more. I don't even know how to make the margins work. I have read all the documentation but just need an example so that will help. But my bigger issue is that the way I have written it is like this: for...
0
1290
by: Bill Eberle | last post by:
In Access 2007 ADP connected to SQL Server Express, most forms allow Text Format attribute of Rich Text, but a few do not. In each case the SQL Server table field connected to the Access Text Box is defined as varchar( MAX ). I see no differences between the sub forms where I'm setting the Text Format attribute to Rich Text and the sub forms where I get the error: "The setting you entered isn't valid for this property" when I try to set the...
0
8481
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8400
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8602
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8672
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4412
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.