473,657 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

centering images vertically...

..

I try to use CSS when possible, though I am still learning and don't maximize its use.

In particular, I still use a table to provide for a centered image in a few slideshows (though table vertical align doesn't work in Mozilla):

http://zintel.com/homepics.html

I've used combinations of <center>, style align 'center', table cell align, valign and height='100%' to get what I want, but I wonder if CSS can do it by itself.

I've tried CSS to align images centrally along the horizontal and vertical but get nowhere vertically, should that be possible (I assume I could do it with a fetch of pic width and height and absolute positioning, but it seems I should let the browser do that with a style align property)

What would be the best way to align an image horizontally and vertically within the available windowspace using CSS?

zin

--
http://www.zintel.com
Jul 20 '05 #1
19 5731
"Stan Brown" <th************ @fastmail.fm> wrote in message
news:MP******** *************** *@news.odyssey. net...
In article <ZPw_a.56801$Ne .28257@fed1read 03> in
comp.infosystem s.www.authoring.stylesheets, George Ziniewicz
<zi**@cox.net > wrote:
In particular, I still use a table to provide for a centered image in a few slideshows(though table vertical align doesn't work in Mozilla):
I don't understand this statement. I use vertical-align all the time
in tables, and it seems to work just fine in Mozilla 1.4 as it did
in 1.2. Have you tried validating your HTML and your CSS?


Not for a few versions, I'll try it.

I'm speaking of centered images (of differing sizes) in the single cell
of a full-window-size table, or a centered table with tight-wrapping of an
image within a cell, either way I get a completely window/document centered
image (though I'd prefer the tight-wrapped version because I have a simple
drop-shadow effect for that one).
The only combination I've got to work in IE is when using a <table
height='100%'.. .> which appears to not work on my Mozilla, not surprising
since the table height attribute seems missing in the spec, and so the table
stays at the top center of the window. I may have missed some combination,
I'll write a small test_table html program and try again.
I use:
<table height='100%' width='100%' border='0'>
<tr>
<td align='center' valign='middle' >

and an img tag w/ no alignment specifiers, which gives me a centered
image in IE and a top-centered image in Mozilla. The use of various style
attributes in various places didn't work for me, but I'll give it a go
again.

http://zintel.com/homepics.html


Your "CSS version" of Rocky Point did not work at all for me --
perhaps because when I view source it was full of Javascript.


Sorry! To me in my infancy, CSS goes with Javascript. By the name I
meant that I replaced an earlier FRAMES version (which replaced an earlier
TABLES version) with a version that uses mostly CSS for positioning. I'll
change the identifier, thanks.

If you're going to link to a JavaScript version and a CSS version of
the same thing, it seems a bit much to have JavaScript in both!


Crazy I know. These are simply the original names of the links, I
haven't gone back to reconsider what to call them as I've upgraded with now
my 5th version of a slideshow which went from pure IE javascript with a
table and minimal controls, to frames to css to [allegedly] cross-browser,
full-screen, zoom with an extensive draggable/hideable menu and multiple
folders. I should move them all to another separate slideshow page where I
can describe them all in detail, or just drop them all for one good
cross-browser version. More to do...

And when I say cross-browser, all I can test on is IE5, Mozilla 1.4 and
Netscape 7.

zin

Jul 20 '05 #2
Els

"George Ziniewicz" <zi**@cox.net > schreef in bericht
news:ZPw_a.5680 1$Ne.28257@fed1 read03...
I try to use CSS when possible, though I am still learning and don't maximize its use.
In particular, I still use a table to provide for a centered
image in a few slideshows (though table vertical align
doesn't work in Mozilla):

http://zintel.com/homepics.html

I've used combinations of <center>, style align 'center',
table cell align, valign and height='100%' to get what I
want, but I wonder if CSS can do it by itself.

I've tried CSS to align images centrally along the
horizontal and vertical but get nowhere vertically,
should that be possible (I assume I could do it with
a fetch of pic width and height and absolute positioning,
but it seems I should let the browser do that with a
style align property)

What would be the best way to align an image
horizontally and vertically within the available
windowspace using CSS?


In alt.html was a thread with subject 'center vertical', starting on
9-8-2003.
The answer to your question is in the end of it, with an example:
http://karlcore.com/100pcttable/100pctcsswithdtd.php

Hope this helps,
sincerely,
Els
Jul 20 '05 #3
"Els" <el*********@PL EASEtiscali.nl> wrote in message
news:bh******** **@reader1.tisc ali.nl...

"George Ziniewicz" <zi**@cox.net > schreef in bericht
news:ZPw_a.5680 1$Ne.28257@fed1 read03...
I try to use CSS when possible, though I am still learning and don't

maximize its use.

In particular, I still use a table to provide for a centered
image in a few slideshows (though table vertical align
doesn't work in Mozilla):

http://zintel.com/homepics.html

I've used combinations of <center>, style align 'center',
table cell align, valign and height='100%' to get what I
want, but I wonder if CSS can do it by itself.

I've tried CSS to align images centrally along the
horizontal and vertical but get nowhere vertically,
should that be possible (I assume I could do it with
a fetch of pic width and height and absolute positioning,
but it seems I should let the browser do that with a
style align property)

What would be the best way to align an image
horizontally and vertically within the available
windowspace using CSS?


In alt.html was a thread with subject 'center vertical', starting on
9-8-2003.
The answer to your question is in the end of it, with an example:
http://karlcore.com/100pcttable/100pctcsswithdtd.php

Hope this helps,


Thanks! I was using table align attributes, and all it really required
was a style height attribute, somehow I missed that.

<table border='1' style='width:10 0%; height:100%;'>
<tr>
<td align='center'>
<img src='aCentered. jpg'>
</td>
</tr>

zin
Jul 20 '05 #4
Els

"George Ziniewicz" <zi**@cox.net > schreef in bericht
news:FfT_a.23$k P.9@fed1read03. ..
"Els" <el*********@PL EASEtiscali.nl> wrote in message
news:bh******** **@reader1.tisc ali.nl...

"George Ziniewicz" <zi**@cox.net > schreef in bericht
news:ZPw_a.5680 1$Ne.28257@fed1 read03...
I try to use CSS when possible, though I am still learning
and don't maximize its use.

What would be the best way to align an image
horizontally and vertically within the available
windowspace using CSS?


In alt.html was a thread with subject 'center vertical', starting on 9-8-2003.
The answer to your question is in the end of it, with an example:
http://karlcore.com/100pcttable/100pctcsswithdtd.php


Thanks! I was using table align attributes, and all it really
required was a style height attribute, somehow I missed that.

<table border='1' style='width:10 0%; height:100%;'>
<tr>
<td align='center'>
<img src='aCentered. jpg'>
</td>
</tr>


No, you need to do more: put a height: 100% style attribute to html
and body as well!
Try it:
if you take out the height: 100% from the body, Mozilla and Netscape
won't display a full height table,
if you take out the height: 100% from the html, none of the browsers
will display a full height table,
so you have to put the 100% height in the styles for html, body, and
table.

Sincerely,
Els

Jul 20 '05 #5
"Els" <el*********@PL EASEtiscali.nl> wrote in message
news:bh******** **@reader1.tisc ali.nl...

"George Ziniewicz" <zi**@cox.net > schreef in bericht
news:ZPw_a.5680 1$Ne.28257@fed1 read03...
> I try to use CSS when possible, though I am still learning
> and don't maximize its use.
>
> What would be the best way to align an image
> horizontally and vertically within the available
> windowspace using CSS?

In alt.html was a thread with subject 'center vertical', starting on 9-8-2003. The answer to your question is in the end of it, with an example:
http://karlcore.com/100pcttable/100pctcsswithdtd.php
Thanks! I was using table align attributes, and all it really
required was a style height attribute, somehow I missed that.

<table border='1' style='width:10 0%; height:100%;'>
<tr>
<td align='center'>
<img src='aCentered. jpg'>
</td>
</tr>


No, you need to do more: put a height: 100% style attribute to html
and body as well!
Try it:
if you take out the height: 100% from the body, Mozilla and Netscape
won't display a full height table,


Mine does, unless you mean an older rev.

if you take out the height: 100% from the html, none of the browsers
will display a full height table,
Mine do. Frustrating for someone trying to learn...

so you have to put the 100% height in the styles for html, body, and
table.


Using just a table style, this works on my IE5, Netscape 7.1 and Mozilla
1.4:

<head>
<title>100% Table With CSS, Valid HTML Strict</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table border='1' style='width:10 0%; height:100%;'>
<tr>
<td align='center'> <img src='bluclouds. jpg'></td>
</tr>
</table>
</body>
</html>

My initial problem seems to be not trying the style height and width
100%. With CSS it seems best to minimize use of HTML positioning
attributes.

zin

Jul 20 '05 #6
"George Ziniewicz" <zi**@cox.net > wrote in message
news:Oq5%a.217$ kP.145@fed1read 03...
"Els" <el*********@PL EASEtiscali.nl> wrote in message
news:bh******** **@reader1.tisc ali.nl...
>
> "George Ziniewicz" <zi**@cox.net > schreef in bericht
> news:ZPw_a.5680 1$Ne.28257@fed1 read03...
> > I try to use CSS when possible, though I am still learning
> > and don't maximize its use.
> >
> > What would be the best way to align an image
> > horizontally and vertically within the available
> > windowspace using CSS?
>
> In alt.html was a thread with subject 'center vertical', starting on 9-8-2003.
> The answer to your question is in the end of it, with an example:
> http://karlcore.com/100pcttable/100pctcsswithdtd.php

Thanks! I was using table align attributes, and all it really
required was a style height attribute, somehow I missed that.

<table border='1' style='width:10 0%; height:100%;'>
<tr>
<td align='center'>
<img src='aCentered. jpg'>
</td>
</tr>


No, you need to do more: put a height: 100% style attribute to html
and body as well!
Try it:
if you take out the height: 100% from the body, Mozilla and Netscape
won't display a full height table,


Mine does, unless you mean an older rev.

if you take out the height: 100% from the html, none of the browsers
will display a full height table,


Mine do. Frustrating for someone trying to learn...

so you have to put the 100% height in the styles for html, body, and
table.


Using just a table style, this works on my IE5, Netscape 7.1 and

Mozilla 1.4:
<head>
<title>100% Table With CSS, Valid HTML Strict</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table border='1' style='width:10 0%; height:100%;'>
<tr>
<td align='center'> <img src='bluclouds. jpg'></td>
</tr>
</table>
</body>
</html>

My initial problem seems to be not trying the style height and width
100%. With CSS it seems best to minimize use of HTML positioning
attributes.


Things get wierder and wierder. Though the above code works on its own
for me, incorporating it into my larger slideshow program doesn't, going
back to the simple case of an image in a table I noticed the simple
inclusion of
a div changed vertical alignment. Investigating it showed that the weblink
article described what I ultimately had to do: go 100% style:height on html,
body,
and table. This stuff is quirky!

This finally worked on both IE & Mozilla at least:

<style type='text/css'>
html{height:100 %;}
body{background :#111111; height:100%;}
table{width:100 %; height:100%;}
</style>
..
..
..
<table border='0'>
<tr><td align='center'>
<img src='centeredPi c.jpg' name='pic' id='pic'>
</td></tr>
</table>

Don't know why the table centering doesn't work in a div, but I removed
it as it is non-essential in this app.

zin

Jul 20 '05 #7
Els

"George Ziniewicz":
"George Ziniewicz":
"Els":
> > "George Ziniewicz": > > > What would be the best way to align an image
> > > horizontally and vertically within the available
> > > windowspace using CSS? > > http://karlcore.com/100pcttable/100pctcsswithdtd.php > Thanks! I was using table align attributes, and all it
> really required was a style height attribute, somehow
> I missed that. No, you need to do more: put a height: 100% style
attribute to html and body as well!
Try it:
if you take out the height: 100% from the body, Mozilla
and Netscape won't display a full height table,
Mine does, unless you mean an older rev.
My Netscape 7.1 doesn't...
if you take out the height: 100% from the html, none of the
browsers will display a full height table,

Mine do. Frustrating for someone trying to learn...
Using just a table style, this works on my IE5, Netscape 7.1
and Mozilla 1.4
I tested it only on Opera 7.11, Netscape 7.1, Mozilla's Firebird and
IE 6.0...
My initial problem seems to be not trying the style height
and width 100%. With CSS it seems best to minimize
use of HTML positioning attributes.

Things get wierder and wierder. Though the above code
works on its own for me, incorporating it into my larger
slideshow program doesn't, going back to the simple case
of an image in a table I noticed the simple inclusion of
a div changed vertical alignment. Investigating it showed
that the weblink article described what I ultimately had to
do: go 100% style:height on html, body, and table.
This stuff is quirky!

This finally worked on both IE & Mozilla at least:

<style type='text/css'>
html{height:100 %;}
body{background :#111111; height:100%;}
table{width:100 %; height:100%;}
</style>
.
.
.
<table border='0'>
<tr><td align='center'>
<img src='centeredPi c.jpg' name='pic' id='pic'>
</td></tr>
</table>

Don't know why the table centering doesn't work in
a div,


Maybe you have to put 100% height on that div as well, as it seems to
me that all the (grand)parents have to be 100% height.
(don't know, haven't tested that yet) If a 100% height table is
inside a div, 100% will only mean 100% of the available height in that
div, so if the div has no specified height... neither has the table
inside of it. (I'm just guessing that you didn't specify a height on
that div, if you did, I don't know the answer to the problem either)

Sincerely,
Els

Jul 20 '05 #8
[Vertical centering in tables]

Well, tables are comparatively easy to deal with. But how can I center an
image vertically in, say, a div?

Curious,
Thomas

Jul 20 '05 #9
"Els" <el************ ***@tiscali.nl. invalid> wrote in message
news:bh******** **@reader1.tisc ali.nl...

"Thomas Mlynarczyk" <bl************ *@hotmail.com> schreef in bericht
news:bh******** *****@news.t-online.com...
[Vertical centering in tables]

Well, tables are comparatively easy to deal with. But how can I

center an
image vertically in, say, a div?

Curious,
Thomas


I wish I knew :(


I've written some code to center an arbitrary image in a 100%/100% div,
but to center it in an arbitrarily sized div requires getting the
div.style.width & height which I can't seem to get, I can set them but not
get them in IE.

zin
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1936
by: Geoff Soper | last post by:
I'm having problems with using CSS to centre an image inside a div. At http://geoffsoper.co.uk/photos/admin/index.php?page=photo I would like the thumbnails to be vertically and horizontally centered within the 'thumbnail_holder' div. Currently I can't get the images to centre vertically. A friend suggested I need to use display:table-cell to get vertical-align:middle to work but this still doesn't seem to work in MSIE (Mozilla is OK). The...
7
6808
by: Aaron | last post by:
Hi, I have a div with an image inside it. The image needs to be centered in the div. I thought I could do this by setting the image's margin to "auto auto", but it seems to do nothing. What am I missing here? Thanks, Aaron P.S. Here are the exact styles I'm using:
2
2141
by: cjl | last post by:
Hey all: I have a div of a known size, 672px X 672px. In it I will display images that are of unknown size. I have two simple functions that shrink and center the image: function shrink() { if (document.getElementById('right').height >= document.getElementById('right').width)
6
2305
by: Jerry Camel | last post by:
I want to center an image on the screen and have text centered over the image. What's the best way to do this? I've been playing with style tags and I can get the stuff to center automatically OR have the text appear on top of the image. But in the second case, the image and text aren't centered properly. Any help is appreciated... Jerry
5
5030
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page that calls the web service to render a vertical strip of images. After doing some research I am unable to find some vb.net code that can assist in what I want to achieve. The closest thing I found was
3
4198
by: John Pote | last post by:
1. Horizontal centering a <divin browser window. The current trend seems to be to place page content in a fixed width area in the middle of the browser window. How is this achieved? If I use a top level <divthen I can place it with CSS attribute 'left:', but this is a fixed offset. Is it possible to have a <divcentered in the browser window? 2. Verticle centering in <div>
5
4815
by: Markus Ernst | last post by:
Hello This is a test example: http://www.markusernst.ch/anthracite/ http://www.markusernst.ch/anthracite/living_divani.html After googling and experimenting for several hours, I ended up doing this demo with tables. The main problems are the vertical centering of the info area, and of the text inside the squares.
1
2276
by: =?Utf-8?B?ZnJhbmt5?= | last post by:
Hello, I've created a table that has two rows that are span across three columns. The third row has three columns, each with an image. The last row is also span accross three columns. The span rows are centering their data. however, the row with three columns, each with images (myimages1-3) are not centering with the rest of the table. Any idea why? Thanks in advance!
4
5279
by: harryusa | last post by:
I am trying to center 2 images concentrically which are z-indexed to lay on top of each other making an image with a border from another image that has a transparent center. I need the images to be horizonally and vertically centered within a <TD> </TD> area. No matter what I do the two image just present one above the other, albeit centered, NOT on top of each other. I originally did the entire page layout in TABLES until I found out I.E. 7...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1953
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.