473,771 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

css positioning (float, div, margin, width...) confusing me like crazy

I've been happily chugging along thinking I understood floating divs
and now find that I know a lot less than I thought I did. And the
more I try "fixing" things, the worse it gets. A lot of what I'd been
doing looked okay in IE 6.0, but in Gecko browsers like my Netscape
7.1 (I've been told they conform better to the standards than does
IE), they look terrible.

http://trialanderror.100freemb.com/2...5FloatDiv.html is a page I
put together with some issues I'm struggling with, and it should be
easy to view my css/html and offer me suggestions.

The borders that I use on the page are merely intended to clearly show
the area of the various divs; I realize that the width of the borders
does have an impact on the screen width available for my use.

Basically, my issues that I can think of are at least:

1. I want a box on the left edge of the browser window. Next to it, I
want a box with its left edge immediately to the right of the first
box, and its right edge to be the very edge of the browser window.
Yet I cannot figure out how to make that happen automatically; I have
to manually size that box. What am I doing wrong?

2. If I have an area of the screen (the whole screen, half the screen,
400 pixels worth; whatever) and want to have four (or any number) of
objects spread out evenly spaced within that area, what is the easiest
correct way to do it? Again, I'd like to have the browser figure out
where to put them, rather than me manually calculating spacing, and
have the visual appearance survive a resizing of the browser window.

3. In the above example that I have posted, the objects display
OUTSIDE the box I'd expect them to be in, at least in Netscape 7.x.
Why?

4. I am sure that my way of doing even things that seem to render okay
could be improved.

I think a look at
http://trialanderror.100freemb.com/2...5FloatDiv.html will be more
clear than reading the above. Thanks in advance to all for any help
or suggestions.
Jul 20 '05 #1
1 4741
In article trialanderror wrote:
I've been happily chugging along thinking I understood floating divs
and now find that I know a lot less than I thought I did. And the
more I try "fixing" things, the worse it gets. A lot of what I'd been
doing looked okay in IE 6.0, but in Gecko browsers like my Netscape
7.1 (I've been told they conform better to the standards than does
IE), they look terrible.
Have you read and understood CSS box modell from spec? Notice that it is
different than IE with quirks mode.
http://trialanderror.100freemb.com/2...5FloatDiv.html is a page I
put together with some issues I'm struggling with, and it should be
easy to view my css/html and offer me suggestions.

The borders that I use on the page are merely intended to clearly show
the area of the various divs; I realize that the width of the borders
does have an impact on the screen width available for my use.
And many other things too. If you need help for some real case, include
all "irrelevant " info too, like if you want to use borders/background
colors. Those pretty often make things more complicated.
Basically, my issues that I can think of are at least:

1. I want a box on the left edge of the browser window. Next to it, I
want a box with its left edge immediately to the right of the first
box, and its right edge to be the very edge of the browser window.
Yet I cannot figure out how to make that happen automatically; I have
to manually size that box. What am I doing wrong?
You are floating them both. Only float the other. Use left margin same
size as float for no-floated.
2. If I have an area of the screen (the whole screen, half the screen,
400 pixels worth; whatever) and want to have four (or any number) of
objects spread out evenly spaced within that area, what is the easiest
correct way to do it? Again, I'd like to have the browser figure out
where to put them, rather than me manually calculating spacing, and
have the visual appearance survive a resizing of the browser window.
You could say
wrapper {text-align:center;}
object {display:inline-table;}

It does work on Opera 6+ (maybe 5, can't remember, but none else.)

I don't think other browsers allow any sencible way.
3. In the above example that I have posted, the objects display
OUTSIDE the box I'd expect them to be in, at least in Netscape 7.x.
Why?
Floats are taken out of flow, and box measures don't change because of
floats. Floats only affect line boxes. Above way would solve this too.
4. I am sure that my way of doing even things that seem to render okay
could be improved.


Unfortunately with CSS, the best way don't necessarily work (with html,
this case is somewhat rarer, fortunately). When doing layouts, it is
surprisingly often dispaly:inline-table is easiest way to do things. It
is not once or twice when you get thing working using few rules, and then
make it work with IE and end up with 5 times more code and it is not even
as usable.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #2

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

Similar topics

12
2457
by: Secret Guy | last post by:
I'm trying to understand generally how to make a grid of variously sized boxes using CSS. The first idea I had was to make a box where I can see the margin, padding, border and content edges, and understand why they have the areas that they do. And I'm having trouble... I read in the 2.1 spec, that the height and width properties specify the height and width of boxes generated by applicable elements, and that a percentage value is taken...
5
8104
by: Joy | last post by:
Hi guys, I am in a tricky situation, I really really hope someone will help me. I got a layout with a main container and three colums inside. Main container: 100% height; 90% width; float: left First colum: 100% height; 200px width; float: left Second colum: 100% height; 200px width; float: right Third colum: 100% height And here I stop, because nothing seems to work in order to set correctly
2
2680
by: Viken Karaguesian | last post by:
Hello all, This question is half css and half html based, so I chose this group. I have a theortical question. When positioning floating <div>'s, how much does it matter what order you put itin in the html? Consider this situation. In the website I run, I use two column liquid layout modeled after the one here: http://www.alistapart.com/articles/negativemargins/
1
1361
by: Luciano A. Ferrer | last post by:
Hi, I am trying to achieve this simple layout http://img478.imageshack.us/my.php?image=boceto2ah.gif and I have problems with the navigation div (the numbers) btw, the right way its somthing like 1234 5678 at bottom of that line, not vertical like that image
8
3818
by: Woodchuck | last post by:
Hi:) I've been trying to position some element's on my page and I can't come up with a way to equally position 4 DIV's in another DIV without explicitly setting the width of the "child" DIV's. Here's what the code look's like: <div id="Heading"> <a id="WP">WERSJA POLSKA</a> <div id="Buttons"> <div id="Home" class="ButtPart"><img src="Images/Buttons/blank_button.gif" alt="" class="InButtPart" />
3
3061
by: goldenboy651 | last post by:
My Positioning in IE 6 is exactly the way I want it, but when I view the page in my firefox browser things are out of place. When I try and change the css my IE page moves, but the firefox doesn't. Any help would be greatly appreciated. I have set the margin and padding to 0. I am new to html and css so I don't know what else to try. Thanks I have a doc type... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
2
1871
by: nicky77 | last post by:
Hi there, I've uncovered a problem which I only have with IE6, surprise surprise. I have a centered layout for the main content of my web page and I am populating the main section with tabulated data pulled from a database. However, in IE6, the main section of the page is pushed to the left, while the background image (a gold box) i've used to contain the table data has been pushed out to the right. The strange thing about this is that my...
2
2474
by: Slick50 | last post by:
I am about ready to finally give up on CSS and fall back to tables. Positioning is becoming too frustrating for the novice with CSS alone... I have a simple form. Conceptually I divide up each input of user information into rows. On one particular row I want a label to be displayed on the left, a <textareainput in the middle, and some text on the right - all on the same line. This all seems to work fine until the text on the right...
4
4333
by: Christopera | last post by:
Hello, I have built a site that uses two divs, one verticle, and one horizontal as graphic style for the ite. The problem I am having is that if the browser is resized very small the divs are then smaller than the website is wide. I have tried fixed positioning but then i get the dreaded overlap when the browser is smaller than the website. Absolute positioning gets rid of the overlap but then brings on the width issue. Is there a way to...
0
9619
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
10103
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...
1
10038
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
9911
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
8934
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...
0
5354
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...
1
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.