|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
Learning CSS and trying to convert a table layout to DIVs. Example..... PHP Code:
Problem: How do I align the vertical columns (nav buttons especially)? I don't know enough about DIVs to know how to align them flush against each other. That's 6 columns of graphic images.Could someone post a code example to learn from? Heads up welcome. ![]() |
|
#2
|
||||
|
||||
|
Code:
<style type="text/css">
#banner
{
float: left;
width: 100%;
}
#nav1
{
clear: left;
}
.nav
{
float: left;
width: 20%;
}
#menu
{
clear: left;
float: left;
width: 20%;
}
#intro
{
float: left;
width: 80%;
}
#main
{
clear: left;
width: 100%;
}
Code:
<div id="banner">Banner</div> <div id="nav1" class="nav">Nav 1</div> <div id="nav2" class="nav">Nav 2</div> <div id="nav3" class="nav">Nav 3</div> <div id="nav4" class="nav">Nav 4</div> <div id="nav4" class="nav">Nav 5</div> <div id="menu">Menu</div> <div id="intro">Intro</div> <div id="main">Main</div>
__________________
# Jeremy Explain your problem instead of asking how to do what you decided was the solution. |
|
#3
|
||||
|
||||
|
Here's another approach. It combines float and static positioning. http://garyblue.port5.com/webdev/layouttrial.html
I also highly recommend Big John's site, /*Position Is Everything*/. Every article is worthy of study. cheers, gary
__________________
There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing. My html and css workshop, demos and tutorials. Ask a better question, get a better answer. |
|
#4
|
|||
|
|||
|
Thank you, guys!
Did the trick! Been experimenting this morning and figured out the DIVs needed a "wrapper". Was doing it without one, with quite unpredictable results. :/Have to get into the mindset of treating DIVs just like nesting tables. Trying to code this page as XHTML with an external CSS. It sure does look more organized than trying to nest 10 tables! Thanks again, Taro |
|
#5
|
||||
|
||||
|
Quote:
Notice that in my example, except for the unnecessary wrapper, there is no nesting. Everything is positioned by floating or using the normal flow. The wrapper div is a convenience only. It allows for easy sizing and, in this case, centering. The size was set as a percentage of the viewport. It could just as easily been made fixed, or proportional to the user's font size. cheers, gary |
|
#6
|
|||
|
|||
|
Quote:
How about vertical aligning? ![]() Experimenting with the positioning between browsers (IE 6; Opera; Mozilla Firefox; Netscape 7) and can't seem to get Firefox or Netscape to be flush with the top (no top margin). Is there a way around that besides two seperate stylesheets? |
|
#7
|
||||
|
||||
|
Try no top padding either:
Code:
body
{
margin: 0;
padding: 0;
}
|
|
#8
|
|||
|
|||
|
Quote:
I've been playing around with a similar layout scheme and have had some interesting results when using a percentage to state the width of the .nav div. IE and Mozilla each interpreted it differently (based on padding, margin and border size) and in one browser it would wrap, while in the other it would be perfectly sized. (I had an overall div to center the content, which was a fixed width and that caused it to wrap). Weird stuff. |
|
#9
|
||||
|
||||
|
Not wierd at all ... very common and well documented. In short: Microsoft can't read. Basically, they didn't read the w3c recommendation correctly and screwed everything up. IE5.X includes the padding, margin, and borders in the width, while Mozilla does it right and adds the padding, margin, borders to the width.
http://glish.com/css is a good place to read more on the problem and get solutions. |
|
#10
|
|||
|
|||
|
This is the code I'm experimenting with......
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>How do you vertical align elements in Mozilla?</title>
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
body {
margin : 0;
padding : 0;
background-color : #000;
}
#wrapper {
width : 98%;
margin-top : 0;
margin-bottom : 0;
margin-left : 10px;
margin-right : 0;
background-color : #000;
}
#text {
float : left;
width : auto;
height : auto;
background-color : #000;
font-family : Verdana, Arial, Helvetica, sans-serif;
font-size : 14px;
font-weight : bold;
color : #969696;
text-align : justify;
}
.photo1 {
float : left;
margin-top : 1em;
margin-left : 0;
margin-right : 1em;
margin-bottom : 2em;
}
.photo2 {
float : right;
margin-top : 1em;
margin-left : 1em;
margin-right : 0;
margin-bottom : 2em;
}
/*]]>*/--></style>
</head>
<body>
<div id="wrapper">
<div id="text">
<p><span class="photo1"><img src="/images/xhtml/whatthe.png" width="200" height="220" longdesc="/i_am/a/designer/not_a/programmer/index.htm" alt="What the heck is this?" /></span>Some sample text that has no other other reason but to show the alignment of text on this page. Interesting that it will break only at certain points.
<span class="photo2"><img src="/images/xhtml/onestandardplease.png" width="200" height="220" longdesc="/too_many/browsers/index.htm" alt="How many browsers now must we design for?" /></span>Some sample text that has no other other example of example but to show the alignment of text on this page. Interesting that it will break only at certain points. Mozilla Firefox and Netscape 7 are claimed to be swell browsers, yet are a b*tch to wrap a design around.</p>
</div>
</div>
</body>
</html>
Perhaps someone can spot where the problem is, as the code is W3C validated. Taro |
|
#11
|
||||
|
||||
|
What exactly are you trying to align vertically? Tell me what you expect this to look like.
|