Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-02-2011, 01:22 AM   PM User | #1
anhyee
New Coder

 
Join Date: May 2011
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
anhyee is an unknown quantity at this point
How to keep a button fixed

So this is my site that I have so far, http://andynguytest.hosterbox.net/
And I noticed that my buttons jump lines if the screen becomes to small.


I was wondering what I can do to make the buttons stay fixed on one line.

This is my code, can someone critique and tell me what I'm doing wrong?
I just compiled a bunch of tips I found on google for this site.

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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>Andy Nguy - Photography</title>
</style>
</head>	
<body style="background: #000 url('images/background.jpg') no-repeat fixed"> 
<br>
<center>
<img src="images/banner2.png"/>
<br>
<img src="images/home3.png"/><img src="images/about1.png"
onmouseover="this.src='images/about2.png'"
onmouseout="this.src='images/about1.png'"><img src="images/portfolio1.png"
onmouseover="this.src='images/portfolio2.png'"
onmouseout="this.src='images/portfolio1.png'"><img src="images/contact1.png"
onmouseover="this.src='images/contact2.png'"
onmouseout="this.src='images/contact1.png'">
</center>
</body>
</html>

Last edited by anhyee; 05-02-2011 at 02:24 AM..
anhyee is offline   Reply With Quote
Old 05-02-2011, 01:58 AM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
You should validate and correct your HTML first:

You need a !DOCTYPE declaration,
Your 'body' tag starts within the 'head',
You haven't properly closed the 'body' tag.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 05-02-2011, 02:03 AM   PM User | #3
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
What AndrewGSW said
and the w3c validator is at http://validator.w3.org/

If you don't declare a doctype your browser will probably go into quirksmode.

Last edited by bullant; 05-02-2011 at 02:09 AM..
bullant is offline   Reply With Quote
Old 05-02-2011, 02:24 AM   PM User | #4
anhyee
New Coder

 
Join Date: May 2011
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
anhyee is an unknown quantity at this point
ooo I never knew about that tool! Thanks a lot, that really helped.

so here's the updated version
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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>Andy Nguy - Photography</title>
</style>
</head>	
<body style="background: #000 url('images/background.jpg') no-repeat fixed"> 
<br>
<center>
<img src="images/banner2.png"/>
<br>
<img src="images/home3.png"/><img src="images/about1.png"
onmouseover="this.src='images/about2.png'"
onmouseout="this.src='images/about1.png'"><img src="images/portfolio1.png"
onmouseover="this.src='images/portfolio2.png'"
onmouseout="this.src='images/portfolio1.png'"><img src="images/contact1.png"
onmouseover="this.src='images/contact2.png'"
onmouseout="this.src='images/contact1.png'">
</center>
</body>
</html>
anhyee is offline   Reply With Quote
Old 05-02-2011, 04:22 AM   PM User | #5
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
Quote:
Originally Posted by anhyee View Post
ooo I never knew about that tool! Thanks a lot, that really helped.

so here's the updated version
no problem but your updated code is still not valid html and has lots of errors in it. Maybe use that tool to help you fix your html first like Andrew suggested.

If you run your code through the validator, it will tell you what your errors are.

Last edited by bullant; 05-02-2011 at 04:25 AM..
bullant is offline   Reply With Quote
Old 05-02-2011, 11:00 AM   PM User | #6
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Impressive to have 16 errors in 23 lines of HTML
Attached Thumbnails
Click image for larger version

Name:	errors1.png
Views:	14
Size:	3.8 KB
ID:	9728  
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 05-02-2011, 02:14 PM   PM User | #7
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
More to the point of your initial question, ideally you would have a navigation bar in an unordered list. You dont have that. You also dont have ANY containing elements other than to use the outdated deprecated <center> tag.

When you say your images "jump" when the screen becomes smaller. Thats because you dont have them in an element with a specified width that will force them to stay inline where you want them. So if they were in an unordered list within a div, then you could set the width if the <ul> to say 400px or whatever suits your needs, then they wouldnt break out of their containing element.

But, if you expect to have cross browser compliant code, you NEED to fix your errors.
__________________
Teed

Last edited by teedoff; 05-02-2011 at 02:21 PM..
teedoff is offline   Reply With Quote
Old 05-02-2011, 02:56 PM   PM User | #8
coothead
Senior Coder

 
coothead's Avatar
 
Join Date: Jan 2004
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 1,545
Thanks: 0
Thanked 195 Times in 191 Posts
coothead will become famous soon enough
Hi there anhyee,

check out the attachment for a possible solution to your problem.

coothead
 
Attached Files
File Type: zip anhyee.zip (29.5 KB, 14 views)

Last edited by coothead; 05-02-2011 at 05:14 PM..
coothead is offline   Reply With Quote
Old 05-03-2011, 03:57 AM   PM User | #9
anhyee
New Coder

 
Join Date: May 2011
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
anhyee is an unknown quantity at this point
Thanks coothead!
That is the solution (:
I really appreciate it, I ignored the use of CSS ):

Thanks again!
anhyee is offline   Reply With Quote
Old 05-03-2011, 08:27 AM   PM User | #10
coothead
Senior Coder

 
coothead's Avatar
 
Join Date: Jan 2004
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 1,545
Thanks: 0
Thanked 195 Times in 191 Posts
coothead will become famous soon enough
No problem, you're very welcome.
coothead is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:24 PM.


Advertisement
Log in to turn off these ads.