iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Graphics & Design Discussion Forum Post your graphics design questions/comments/ideas in here. Ask questions, post tutorials, discuss trends and best practices. Sub-forum for website accessibility and usability.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-25-2004, 05:26 PM
WebProWorld Member
 
Join Date: Nov 2003
Posts: 95
TheDoctor RepRank 0
Default How do you center an image vertically and horizontally...

How do you center and image vertically and horizontally so that from any size screen it will be prefectly centered?

Thanks
Reply With Quote
  #2 (permalink)  
Old 02-25-2004, 05:52 PM
WebProWorld Member
 
Join Date: Nov 2003
Posts: 95
TheDoctor RepRank 0
Default

OK, I figured out how to do it horizontally but how do you do it vertically?

Thanks
Reply With Quote
  #3 (permalink)  
Old 02-25-2004, 06:19 PM
WebProWorld 1,000+ Club
 
Join Date: Aug 2003
Location: Edmonton, AB, Canada
Posts: 1,527
mikmik RepRank 2mikmik RepRank 2
Default

My first thought, would be to have a good look at what the rest of your pqge contains, block wise.

So, I would put it in an 'absolutely' positiond div with a height of 100%, and put the image in another div with position: relative.

Make good and sure you do not change any 'Z-ndexes', because luckily, when a relatively positioned box is in an 'absolute' container, all inline elements will will flow around the picture , and not ignore it and go over or under it like is usually the case .

I will get back to you, so if it is not working out, would you show us the page?

Many happy returns, ..

Hey, we are going to be going through dealing with all these types of issues in a week or two.
Make sure you check out the thing we have going on in web programming, I hope it hasn't been messed up to badly with all the sudden activity and shuffling, but it will be great and things will become familiar to us again very quickly.

There are some finer details, like the order they are coded in, that we can watch out for if you can give us a look :o)
Reply With Quote
  #4 (permalink)  
Old 02-25-2004, 06:25 PM
DigitalDragon's Avatar
WebProWorld Member
 
Join Date: Sep 2003
Posts: 45
DigitalDragon RepRank 0
Default

There are a couple of ways (depending upon the effect you want to achieve and how many other elements you have on the page). Off the top of my head:

1.Use CSS.

for example:

<style type="text/css">
<!--
.unnamed1 {
left: 40%;
top: 40%;
position: relative;
}
-->
</style>
[img]blahblah.png[/img]

I recommend you search for more information about CSS and positioning, before going ahead and using it.

2. Stick it in a table.

for example:

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle">[img]blahblah.png[/img]</td>
</tr>
</table>

The old fashioned lazy way. Pretty straightforward if it's the only image on a page, or the only image object contained within a table cell element.

3. Use DIV's, as already mentioned. Beware though; research carefully. Both CSS and layers (DIV, etc) have compatibility issues. Only sticking it in a table cell will pretty much stay consistent throughout platform and browser version.

I'm sure there are more. If you give me a more specific example of what you are doing, maybe I can help you further?
Reply With Quote
  #5 (permalink)  
Old 02-25-2004, 06:40 PM
WebProWorld Member
 
Join Date: Nov 2003
Posts: 95
TheDoctor RepRank 0
Default

There is only the image on the page. What is the easiest way to do it? I know there is a html or java script that should center it vertically. Does anybody know whatit is?

Thanks
Reply With Quote
  #6 (permalink)  
Old 02-25-2004, 06:57 PM
DigitalDragon's Avatar
WebProWorld Member
 
Join Date: Sep 2003
Posts: 45
DigitalDragon RepRank 0
Default

If it's just the image, use the table cell example I mentioned.
It'll work just fine.

BTW: I just had a flick through of all your posts. If you need a lot of help, one of the best ways to really learn something is to research it yourself first. Not that anyone here minds helping, but, when someone doesn't look like they've even tried to solve a problem themselves, and continues to ask for more help, it can eventually get frustrating. Please don't think I'm having a go at you or anything, it's just that, in my personal experience, the only way I learned something and made it stick was by doing it myself. If I still really couldn't figure it out, then I'd ask for help, citing examples of what I had tried.

Google is NOT your friend, but feel free to use AltaVista or Yahoo.

Take care and happy searching!
Reply With Quote
  #7 (permalink)  
Old 02-25-2004, 07:35 PM
WebProWorld Member
 
Join Date: Nov 2003
Posts: 95
TheDoctor RepRank 0
Default

I know there is a better way to do it than that?

There is a script it's align somethign etc.

Anydboy know it?

Thanks
Reply With Quote
  #8 (permalink)  
Old 02-25-2004, 08:19 PM
WebProWorld 1,000+ Club
 
Join Date: Jul 2003
Location: Western Australia
Posts: 1,336
matauri RepRank 0
Default

What format are you using? HTML / XHTML / PHP, etc... with or without CSS?

It's always a good idea to include this so we know what kind of coding & standards we are looking at.



Cindy
__________________
Web Development Community ::: Forum ::: Library

It' time for Progressive Web & IT Development!
Reply With Quote
  #9 (permalink)  
Old 02-25-2004, 08:42 PM
paulhiles's Avatar
WebProWorld 1,000+ Club
 
Join Date: Jul 2003
Location: UK
Posts: 2,089
paulhiles RepRank 0
Default

This may be on the lines of what you're after... I'm not sure whether it's a 100% cross-browser friendly, but take a look anyway. You would just substitute the text with your image.
http://www.wpdfd.com/editorial/thebox/deadcentre1.html

Paul
Reply With Quote
  #10 (permalink)  
Old 02-25-2004, 09:01 PM
WebProWorld Member
 
Join Date: Nov 2003
Posts: 95
TheDoctor RepRank 0
Default

HTML would work.

Thanks
Reply With Quote
  #11 (permalink)  
Old 02-26-2004, 11:13 AM
DigitalDragon's Avatar
WebProWorld Member
 
Join Date: Sep 2003
Posts: 45
DigitalDragon RepRank 0
Default

Well, I had already brought up CSS.

If you know there's a better way to do it than the most basic method (i.e. the table cell method) why are you here asking us for help?

The very good example paulhiles mentioned is exactly what I said in my first example - use CSS. Maybe you didn't see the bit about me encouraging you to find out a wee bit more on your own.

I'm sorry if what you're looking for is the EXACT solution to you problem, explicitly laid out for you, so you don't have to do ANYTHING except cut and paste. Any news group treated the way you have treated us here would tell you, politely, to leave. I've seen it many times.

Also, everyone here has asked you for more information, in order to help you further, but you failed to give it.

I'm sorry, but you seem a little too demanding and ungrateful to me. Maybe I don't know you well enough, but as I said, I did go through and read all your posts here.
Reply With Quote
Reply

  WebProWorld > Site Design > Graphics & Design Discussion Forum

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:24 AM.



Search Engine Optimization by vBSEO 3.3.0