473,789 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

White Space on Top?

Hello!

Im looking to try and get into CSS for formatting my sites. Seems like a
nice premise, and should allow easier design for the future. But gees,
Im having a hard time of it.

I would like to create something like at http://www.blargle.co.uk or
http://www.celebrityresearcher.co.uk without the tables.

I figure should be easy, to have two DIV rows, 100% width, and then have
three DIV columns underneath...

I couldn't even get past the two rows.

When I use absolute positioning, Firefox draws everything in the right
place, but doesn't give me 100% width. Unlike IE. However if I remove
the position property, Firefox does indeed draw the DIVS to the full
width of the screen.

Except, it also includes a white space at the top, like some kind of
margin! I've tried to set all margins to 0px and padding to 0px, but
still the white space on top remains - Unless I add a border, then it
all draws in the correct places.

Curiously, the differences between border 1px and border 0px seems to
just move the box while any text inside stays at the same position on
the screen.

Im confused...

I don't want to use border:1px and it seems most of everyone out there
uses borders, or separation between DIV elements, whereas I want to
retain my designs...

Sorry, I havent got any code on me, Im at work at the moment, and what I
have is at home, but I just wanted to run this past you. I am a newbie,
I have much to learn, I have searched, but can't find much in relation
to this particular issue. There's probably some glaringly obvious mistake.

Cheers
Simon

PS I'll try and post a URL tonight, but I think I have something like:

<div id=banner1>
<p>some text</p>
</div>
<div id=banner2>
<p>some text</p>
</div>

#banner1 {
background:#f00 ;
top:0px;
height:50px;
left:0px;
width=100%px;
}

#banner2 {
background:#0f0 ;
top:0px;
height:50px;
left:0px;
width=100%px;
}
Jul 21 '05 #1
3 9018
Simon Dean <sj****@simtext .plus.com> wrote:
I figure should be easy, to have two DIV rows, 100% width, and then have
three DIV columns underneath...

I couldn't even get past the two rows.

When I use absolute positioning, Firefox draws everything in the right
place, but doesn't give me 100% width. Unlike IE. However if I remove
the position property, Firefox does indeed draw the DIVS to the full
width of the screen.
You should always set a width for absolutely positioned elements. If
you don't then, as you've seen, browser behaviour varies. But I doubt
that you need absolute positioning at all.
Except, it also includes a white space at the top, like some kind of
margin! I've tried to set all margins to 0px and padding to 0px, but
still the white space on top remains - Unless I add a border, then it
all draws in the correct places.

Curiously, the differences between border 1px and border 0px seems to
just move the box while any text inside stays at the same position on
the screen. <div id=banner1>
<p>some text</p>
</div>
<div id=banner2>
<p>some text</p>
</div>


The paragraphs have a default top margin. Under CSS margin collapsing
rules this will collapse with the top margin of the parent div. So you
end up with a margin above the div that is the larger of the margin
set on the div (default zero) and the margin set on the paragraph
(default about one line height). See
http://www.w3.org/TR/CSS21/box.html#x25

To prevent margin collapsing the div needs a non-zero amount of either
padding or border. Or you can remove the margin-top from the first
paragraph via the :first-child selector (not supported by IE but as IE
doesn't collpase margins properly not an issue).

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 21 '05 #2

You should always set a width for absolutely positioned elements. If
you don't then, as you've seen, browser behaviour varies. But I doubt
that you need absolute positioning at all.


Yes, must wrap my head around what they all mean, absolute should be
fairly straight forward, but static and relative are two unknowns to me
at the moment.

Curiously, the differences between border 1px and border 0px seems to
just move the box while any text inside stays at the same position on
the screen.


<div id=banner1>
<p>some text</p>
</div>
<div id=banner2>
<p>some text</p>
</div>

The paragraphs have a default top margin. Under CSS margin collapsing
rules this will collapse with the top margin of the parent div. So you
end up with a margin above the div that is the larger of the margin
set on the div (default zero) and the margin set on the paragraph
(default about one line height). See
http://www.w3.org/TR/CSS21/box.html#x25

To prevent margin collapsing the div needs a non-zero amount of either
padding or border. Or you can remove the margin-top from the first
paragraph via the :first-child selector (not supported by IE but as IE
doesn't collpase margins properly not an issue).


Ahh, OK, I think I just about understand that... Failed to realise that
it would seem from this newbies point of view, that each html tag can
have a property... I forgot about the <p> tag!

There sounds like a hell of a lot to learn, but it all seems so
flexible and customisable... should be interesting.

Thank you very much for your kind help!

Cheers
Simon
Jul 21 '05 #3
look at a few templates, to become familiar

http://wholives.com/tools/freestuff.htm

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
16175
by: Grumble | last post by:
Hello all, I want to read lines from a text file, where each line has the following syntax: token1:token2:token3 There could be white space between tokens and ':'
2
2247
by: Malcolm Dew-Jones | last post by:
I am looking at xslt 1.0 and trying to understand if empty text nodes are supposed to be stripped or not as the default behaviour. 3.4 starts by listing rules for when white space is not stripped and then says "Otherwise the text node is stripped". which appears to contradict a later paragraph that discusses the details of the selection of nodes to be stripped ("Initially ... preserve ... all element names").
17
9132
by: Stanimir Stamenkov | last post by:
Is it possible to make two inline elements to appear adjacent stripping any white space appearing in between in the source? Example: <span class="adj">1</span> <span class="adj">2</span> <span class="adj">3</span> --
5
12351
by: Applebrown | last post by:
Hello, basically, I'm just learning intermediate CSS and trying to convert my old table webpage completely to CSS. Hoorah, right? Well, it's not quite going as planned. It's an extremely simple layout, and I'm finding myself stuck with small white space in between my images where I planned for the graphics to be stacked up right on top of one another. Here's the simple vertical layout: width is 640px, centered with a CSS border. I'd...
0
15192
by: Mark Moore | last post by:
I'm trying to layout a couple text input fields and their corresponding labels without using a table. When I was trying to debug my understanding of CSS, I was *very* surprised to see that span's with borders behave counter-intuitively (IMHO) when using style="white-space: nowrap;". Below is a fairly small chunk of XHTML that demonstrates what I'm talking about. What gives? -Mark
5
718
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will preserve formatting (white space and line feeds). However, this is not true when doing the same with the <code> tag listing (it will all be pasted on one line with multiple successive spaces treated as a single space) despite the fact that...
38
24009
by: Xah Lee | last post by:
sometimes i wish to add white space in <p> as to achived effects similar to tab. what should i do? using empty image seems the sure way but rather complicated. (and dosen't change size with font) Woudl some of the space character in unicode work? (my html files uses unicode) Xah
2
6657
by: shagy | last post by:
Hi, I'm having a problem with a <select><option> which has white space in values... When I post the data I only get the first word (up to the white space). "Testing white space" becomes "Testing" after posting code... <select name="descr" id="descr">
5
2576
by: Richard Maher | last post by:
Hi, Can someone please show me how to tell Firefox to preseve white-space when returning the selectList.option.value attribute? I have change the style so that the white-space is preserved on the screen, but for some bizarre reason when I try to substring out a series of bytes (aka a fixed-length string or field) from a given option it squashes everything up and corrupts the result.
4
2126
by: mosesdinakaran | last post by:
Can any one explain how the rule is applied for the following Regular expression $Str = 'the red king'; $Pattern = '/((red|white) (king|queen))/'; preg_match($Pattern,$Str,$Val); Result:
0
9511
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,...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
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
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
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.