Results 1 to 7 of 7

Thread: I want to do it the hard way!

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2001
    Posts
    51

    Talking I want to do it the hard way!

    I'm hoping someone can help me with this, I know how to do what i want with a lot of ugly tables, but i want to do it more elegantly with div elements.

    OK so what i'm trying to do:
    It's a list of staff portraits, with a headshot on the left, and (left-aligned) next to it their name, and on the line below (but still next to the portrait) their position. Then below the picture, a horizontal rule (HR).

    The problem is, if i left align the photo, then i can't get the rule (and the next staff portrait) to go below, they just go next to it.
    And if I don't left-align it, I can't get multiple lines of text next to it!

    Any ideas?

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Can you post the HTML?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2001
    Posts
    51
    I don't have complete html, but here's some pseudo-html to give an idea:

    this is the almost-working, ugly tables method:

    <table>
    <tr><td>
    <img ...> <!--this is the portrait of a person, it will be higher than the text i want next to it -->
    <b>Bob Smith</b><br>
    Senior Architect<br>
    <hr>
    </td></tr>
    <tr><td>
    <img ...>
    <b>Ted Jones</b><br>
    Accountant<br>
    <hr>
    </td></tr>
    ... more people ...
    </table>

    the only thing wrong with this code (apart from using tables) is that the description under the persons name ends up under the photo not to the right like it should be.

    if i ditch the table, then i have this problem: if the image is left aligned, i can't find any way to tell the next persons picture and info to start on the next line after the bottom of the image. if its not left aligned i can only write one line after it, not several.

    does that make sense now? it seems like I am trying to do something very simple, but i just can't find how to make it work...

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    If you are using a tables:
    Code:
    <html>
    	<head>
    		<style type="text/css">
    			.mugshot {
    				width: 200px;
    				height: 200px;
    				border-width: 5px;
    				border: solid blue;
    			}	
    		</style>
    	<body>
    		<table>
    			<tr>
    				<td>
    					<p><b>Dave Carter</b></p>
    					<img src="carterd.jpg" class="mugshot" />
    				</td>
    				<td>
    					<p>Manager</p>
    				</td>
    			</tr>
    				<td>
    					<p><b>Lesley Jeeves</b></p>
    					<img src="jeevesl.jpg" class="mugshot" />
    				</td>
    				<td>
    					<p>Sales Assistant</p>
    				</td>
    			</tr>
    		</table>
    	</body>
    </html>
    Tables are probably better in this case. There is nothing wrong with using them and they don't look messy.

    If you really want an example using div's then let me know and I'll post something later.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2001
    Posts
    51
    yeah you are right visualAd, that will work nicely.

    I've been reading some articles recently about how tables for layout is an abuse of html, and we should all be using divs instead. i guess someone should make divs work better before we can ditch tables hey.

    thanks for the code I'll use it, but if you can figure out a way to do it with div's that would be cool too

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Originally posted by Herbatic
    yeah you are right visualAd, that will work nicely.

    I've been reading some articles recently about how tables for layout is an abuse of html, and we should all be using divs instead. i guess someone should make divs work better before we can ditch tables hey.

    thanks for the code I'll use it, but if you can figure out a way to do it with div's that would be cool too
    I'm niether for or against tables or divs. The way I see it - they are both widely supported by the vast majority of web browsers and which you choose depends on your requirements.

    In my opinion, your problem is easiest to solve using tables, becuase in all honesty it is a table of employees which contains pictures and descriptions.

    I've done a similar page using XHTML and style sheets. Here the stylesheet is controlling the layout of the page elements rather than the table:
    Code:
    <!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>
    		<title>Employees</title>
    		<style type="text/css">
    			.employee {
    				display: block;
    				height: 250px;
    				border-bottom: 3px solid black;
    				margin-bottom: 10px;
    			}
    				
    			.leftside {
    				display: block;
    				float: left;
    				padding: 5px;
    			}
    			
    			.mugshot {
    				display: block;
    				width: 200px;
    				height: 200px;
    				border-width: 5px;
    				border: solid blue;
    			}
    		
    			.name {
    				position: relative;
    				font-weight: bold;
    			}
    
    			.description {
    				position: relative;
    				top: 25px;
    			}				
    		</style>
    	</head>
    	<body>
    		<div class="employee">
    			<div class="leftside">
    				<div class="name">Dave Carter</div>
    				<img class="mugshot" src="carterd.jpg" alt="David Carter"/>
    			</div>
    				
    			<div class="description">Manager</div>
    		</div>
    		
    		<div class="employee">
    			<div class="leftside">
    				<div class="name">Lesley Jeeves</div>
    				<img class="mugshot" src="jeevesl.jpg" alt="Lesley Jeeves" />
    			</div>
    			<div class="description">Sales Assistant</div>
    		</div>
    	</body>
    </html>
    The advantages of using divs become clear when you look at the HTML. You can clearly see each employee has its own DIV and there is no formatting cluttering the HTML code.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7

    Thread Starter
    Member
    Join Date
    Aug 2001
    Posts
    51
    thanks!!
    i've seen examples of using divs before, but when its an example for something that you're trying to do, it is so much more helpful

    someone give visualAd an award!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width