CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 27th, 2004, 06:21 PM
deolmstead deolmstead is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 75 deolmstead User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 37 m 48 sec
Reputation Power: 5
css image positioning question

I'm trying to be a good forward-thinking web designer and am giving the xhtml/css design thing a try with the site I'm currently building. The challenge is to do the whole layout without using a table, but I'm having a hell of a time.

You can see the site now at: http://epoch.pursuedbybear.com - currently, I've got the header and footer table-free, but it's the main content area that's giving me trouble. It's using a table right now, since that's so easy, but I'd like to fix that.

Here's what I want: the page is 750 pixels wide, centered. I would like the text to be on the left taking up about 400 pixels, with the margins it currently has. I would like the image to be on the right, aligned to the very edge of the header and just underneath it - no gaps. I would like a 1px black border on the left and right.

I can ALMOST get there with CSS, but everything I've tried has put the image slightly off (typically not flush against the header or after the text entirely). - you can see my latest efforts at http://epoch.pursuedbybear.com/page2.shtml.

Can anyone offer advice on this? I feel so close, but so infuriatingly far...

Thanks,
Daniel

Reply With Quote
  #2  
Old February 27th, 2004, 06:48 PM
Clan admin's Avatar
Clan admin Clan admin is offline
AZbb founder
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: London, UK
Posts: 843 Clan admin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 52 m 44 sec
Reputation Power: 5
It is quite simple, once you know how.

CSS is quite powerful but you have to get used to THINK differently [so said Steve Jobs ].

Positioning images:
float is your friend here. Let the text float on the left side but then you enter image before the text.

Don't put the image in a div [<div id="mainimage">]

However, I would not even bother with float. I would have put the image in the background of the 'div', and positioned it on the top right. Then I would have used 'padding' to stop the text from running over the image.

Border would be easy. I should not have to tell you how to assign left right borders to any block element.

I noticed that not only that you used tables, you have nested tables. Nested tables are a big no-no for advanced web designer.

So the layout would be:

Code:
---------------------------------------------------------
<header div>
---------------------------------------------------------
<header div>
---------------------------------------------------------
<header div>
---------------------------------------------------------
<content div>
<image here with float: right; so everything runs on its left>
Your text
---------------------------------------------------------
<footer div>
---------------------------------------------------------


Alternatively:
---------------------------------------------------------
<header div>
---------------------------------------------------------
<header div>
---------------------------------------------------------
<header div>
---------------------------------------------------------
<content div with 
background: url(img_home.gif) transparent no-repeat 100% 0%;>
You can adjust the 0% to suit but at the moment it is top-right


Your text with padding: 5px 200px 5px 5px;
the 200px would take care of the image, you can adjust to suit.
---------------------------------------------------------
<footer div>
---------------------------------------------------------


Just a quick few words.

Have fun
__________________
© AZ

AZbb :: AZ Bulletin Board - Secure BBS script, Front page CMS, Chat, No database
Simple Guide to Apache and PHP installation on Windows

Reply With Quote
  #3  
Old February 27th, 2004, 11:42 PM
deolmstead deolmstead is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 75 deolmstead User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 37 m 48 sec
Reputation Power: 5
thanks! works great...now one more thing

Thanks for your help - it works well.

So that got rid of one table. I'd like to get rid of the other one as well, if possible...but I don't know how.

it's almost like a bulleted list, but the images are different for each line. the images should be right-aligned, and the text left-aligned, with a bit of space between them.

You can see what I mean at the current page: http://epoch.pursuedbybear.com - here I'm cheating by using a table. I'd like it to look exactly like this, only without the table.

Any suggestions?
-D

Reply With Quote
  #4  
Old February 28th, 2004, 06:12 AM
Clan admin's Avatar
Clan admin Clan admin is offline
AZbb founder
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: London, UK
Posts: 843 Clan admin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 52 m 44 sec
Reputation Power: 5
The idea was to LEARN from my notes not to copy them.

You have copied one of the options without learning the concept. This way, you would need to get help for each and every element in your design.

I am going to give you the idea, BUT..... you have to get a good dose of RTFM.

Code:
<image div with fixed length, align right &
 use of float to enable the next div to stay on the same line>
<textdiv, aligned left>

ditto


Another way is to use the list as you mentioned.

Start reading the CSS manual and experiment.

Good luck

Last edited by Clan admin : February 28th, 2004 at 09:18 AM. Reason: D*mn Typos. They won't leave me alone ;)

Reply With Quote
  #5  
Old February 28th, 2004, 07:37 AM
tigercat's Avatar
tigercat tigercat is offline
member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Germany
Posts: 89 tigercat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 39 sec
Reputation Power: 6
hi there
here's one suggestion.

replace the complete table with this div-statements
PHP Code:
<div class="newsLogo">
    <
img src="images/logo_CNN.gif" alt="CNN" />
</
div>
<
div>
    <
a href="http://www.cnn.com">A treatment for the symptoms of Dyslexia</a>
</
div>


<
div class="newsLogo">
    <
img src="images/logo_BBC.gif" alt="BBC" />
</
div>
<
div>
    <
a href="http://news.bbc.co.uk/1/hi/education/2624543.stm">Light...</a>
</
div


further add to your css-file
PHP Code:
#bodyblock .newsLogo {
    
width80px;
    
floatleft;
    
padding-right10px;
    
border0px;
    
text-alignright;
    
vertical-alignbottom;


so in mozilla browswer it looks like the file attached.
hope i could help. if you had another idea please post it here.
be good,
tigercat
Attached Images
File Type: gif Screenshot.gif (4.5 KB, 247 views)

Reply With Quote
  #6  
Old February 28th, 2004, 08:35 AM
jfunk's Avatar
jfunk jfunk is offline
Web Head
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: San Diego, CA
Posts: 13 jfunk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I don't know why people automatically assume TABLE-less design when you say XHTML/CSS . XHTML just means stricter HTML and CSS is supposed to separate style from content (yes I said style not positioning). TABLEs STILL have their use. CSS still can't do somethings as well as a good ol' TABLE and you're still going through the same hacks just to get it working in different browsers. I do agree that XHTML/CSS is a good step towards an actual standard for browsers, but XHTML/CSS does not AUTOMATICALLY mean TABLE-less design.

Reply With Quote
  #7  
Old February 28th, 2004, 09:27 AM
Clan admin's Avatar
Clan admin Clan admin is offline
AZbb founder
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: London, UK
Posts: 843 Clan admin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 52 m 44 sec
Reputation Power: 5
Quote:
Originally Posted by tigercat
hi there
here's one suggestion.

replace the complete table with this div-statements

.....


Wasn't that what I had just said?
Code:
<image div with fixed length, align right &
 use of float to enable the next div to stay on the same line>
<textdiv, aligned left>

ditto

I intentionally did not provide the final entries so that the deolmstead would get the chance to read CSS and learn something.

Sometimes providing the final answer is not useful. As per my first post, after providing the final answer, I noticed that deolmstead only copied the answer and did not learn from it therefore the next question which is basically the same as first, aligning block-level elements with the use of float.


Good luck

Reply With Quote
  #8  
Old February 28th, 2004, 01:59 PM
deolmstead deolmstead is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 75 deolmstead User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 37 m 48 sec
Reputation Power: 5
the F Manual

Clan: I've got 'em. I read 'em. They still don't make much sense to me. I've been wrestling with "Eric Meyer on CSS" for a few days now, but it seems like he skips over the really basic stuff for the complex concepts, leaving me to wrestle with things I KNOW should be really simple. It is, as you said, learning to "think" differently.

And I agree with the post about table-less design: I'm not doing this because I think I SHOULD, I'm doing this to see if I CAN - hopefully eventually achieving fluency in both methods.

So rest assured I'm TRYING to learn. I think I've got the typography stuff down, it's the images that are throwing me for a loop.

Thanks, guys. I promise I won't come here for you to tell me how to do every element of my sites.

Best,
-Daniel

Reply With Quote
  #9  
Old February 28th, 2004, 02:42 PM
Clan admin's Avatar
Clan admin Clan admin is offline
AZbb founder
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: London, UK
Posts: 843 Clan admin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 52 m 44 sec
Reputation Power: 5
AFA manual, I only check the source:
http://www.w3.org/TR/1999/REC-CSS1-19990111

It should take a few hours to read it all. I still do [I did it an hour ago] check with above.

Learning to think differently IS the key.

Tables are meant for tabular data. In tables, each box is an individual item.

In table-less design, each item is a LAYER so in a div you have the background layer, the border, then another layer with text etc.

As a general concept, there is place for tables in web design and there is a place for other elements.

Problem is that everybody, myself included, started with using tables as a layout tool rather as a data display tool.

There are occasion that what is desired is not possible to achieve without the use of tables.
But there are many instances that a table is not needed. In general I would say 70% table usage in the net is not needed.

What is the big deal, display does suffer. If you have an entire page in a table, especially for a large and content intensive page, it would take longer for the page to load as the entire page has to load before browser starts to display it.

Same page without tables would display the visible part first and as you are looking at the display continues to download the rest. It can make the difference of seconds especially on a slow connection.

As an example of clean design
http://www.csszengarden.com/ does a very good job without having to resort to tables.

I have seen many others too. I myself have started to rethink my design strategy and try to avoid unnecessary complication whenever possible.

BTW, you are welcomed to come with your problems as we ALL do need some help now and then.
I think it is better to show people what they should do rather than simply provide the answer.


Good luck

Reply With Quote
  #10  
Old February 28th, 2004, 05:37 PM
kk5st's Avatar
kk5st kk5st is offline
Thanks Johnny Hart (BC) R.I.P.
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: May 2003
Location: Dallas
Posts: 4,555 kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 7 h 49 m 53 sec
Reputation Power: 630
Positioning, especially in elastic designs, can be very frustrating and difficult to understand. I highly recommend Big John and Holly Bergevin's /*Position Is Everything*/. Their explanations of just what is going on are very in-depth, yet clear enough for even me to understand (mostly).

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.

Ask a better question, get a better answer.

Reply With Quote
  #11  
Old February 28th, 2004, 08:29 PM
Sexay_Hamster Sexay_Hamster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 65 Sexay_Hamster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
dont avoid tables totally... if part of the layout is truly tabular data like sidebar links then by all means use them... just use the CSS for everything else.

Reply With Quote
  #12  
Old February 29th, 2004, 01:00 AM
deolmstead deolmstead is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 75 deolmstead User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 37 m 48 sec
Reputation Power: 5
OK. Diligent student that I am, I've tried applying the rules that I learned on the newslogo table to the last remaining table on my site. On the contact page, the contact information falls into two neat columns tucked under the header - witness the table version here: http://epoch.pursuedbybear.com/contact.shtml

So (with much experimentation), says I, I will create two divs, one for the left column and one for the right. I write the following code:

PHP Code:
<div class="firstcol">
Epoch InnovationsInc.<br />
111 Sutter StreetSuite 500<br />
San FranciscoCA 94104</div>

<
div class="secondcol">
Phone415-395-0840<br />
Fax415-395-0978<br />
<
a href="http://maps.yahoo.com/maps_result?ed=fq3lz.p_0tok2avfgdrvv_1v2g--&csz=san%2bfrancisco,%2bca&country=us" target="_blank">View a map </a>
</
div


and write these two classes in my css file:

PHP Code:
.firstcol {
    
width200px;
    
floatleft;
    
text-alignleft;
    
margin-top: -20px;
    
padding0px 15px 15px 35px;
}

.
secondcol {
    
text-alignleft;
    
margin-top: -20px;
    
padding-bottom15px;
    
padding-left200px;



This looks jim-dandy in PC IE6, but a wreck in Mozilla - see http://epoch.pursuedbybear.com/contact2.shtml for yourself. If you don't happen to have Mozilla installed, I will describe it. The first line of the first div has sunk so only the tops of the tallest letters are visible. The next two lines are fine. The first two lines of the second div are much further left than they should be, but the third line (a link) is perfectly placed.

Has anyone come across this problem before? Is there a better way to write this that will make Mozilla (and presumably other non-IE browsers) happy?

Thanks,
Daniel

Reply With Quote
  #13  
Old February 29th, 2004, 04:02 AM
kk5st's Avatar
kk5st kk5st is offline
Thanks Johnny Hart (BC) R.I.P.
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: May 2003
Location: Dallas
Posts: 4,555 kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 7 h 49 m 53 sec
Reputation Power: 630
I don't know why .secondcol was offset to the left, but I do know what happened to the first line of .firstcol. It was shoved up under the contact image. What you see is the below