473,413 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Centering images

Abs
Hi!

I'm having a little problem with my site. I know how to center DIVs
using the "margin: auto" thing. But I'm unable to center two images.
I used the "text-align: center" hack with no results, too.

Here is my site:

http://project.fotografist.com/
and the CSS:

http://project.fotografist.com/styles/styles_black.css
Basically, I need to center the images in the "photos" DIV.
Can someone help me, please ?
thanks in advance
Jul 20 '05 #1
5 2959
Els
Abs wrote:
Hi!

I'm having a little problem with my site. I know how to
center DIVs
using the "margin: auto" thing. But I'm unable to center
two images. I used the "text-align: center" hack with no
results, too.

Here is my site:

http://project.fotografist.com/
and the CSS:

http://project.fotografist.com/styles/styles_black.css
Basically, I need to center the images in the "photos" DIV.
Can someone help me, please ?


I'm not sure what it is you want: center them one below the
other? or next to each other?

You are using float:left on the div which surrounds the first
img, this will never get it centered. Float:left means left,
not centered.
Also you don't need to put divs around the img's, you can
apply the styles to the img elements themselves.

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 20 '05 #2
Abs
Els wrote:

I'm not sure what it is you want: center them one below the
other? or next to each other?
yes, one next to the other.
You are using float:left on the div which surrounds the first
img, this will never get it centered. Float:left means left,
not centered.
Also you don't need to put divs around the img's, you can
apply the styles to the img elements themselves.


Ok, I'll try with no DIVs surrounding the images.
Jul 20 '05 #3
Abs
Abs wrote:
Els wrote:

I'm not sure what it is you want: center them one below the other? or
next to each other?

yes, one next to the other.
You are using float:left on the div which surrounds the first img,
this will never get it centered. Float:left means left, not centered.
Also you don't need to put divs around the img's, you can apply the
styles to the img elements themselves.


Ok, I'll try with no DIVs surrounding the images.


Great, it works now. But I don't know if the text-align hack is the
right way to do it. Anyways...
Jul 20 '05 #4
Els
Abs wrote:
Abs wrote:
Els wrote:

I'm not sure what it is you want: center them one below
the other? or next to each other?

yes, one next to the other.
You are using float:left on the div which surrounds the
first img, this will never get it centered. Float:left
means left, not centered. Also you don't need to put divs
around the img's, you can apply the styles to the img
elements themselves.


Ok, I'll try with no DIVs surrounding the images.


Great, it works now. But I don't know if the text-align
hack is the right way to do it. Anyways...


You must notice though, that in IE, if the window is narrower
than the width of the two pictures, it won't be centered
anymore. In Gecko browsers, it will remain centered, thus
'losing' the left side of the left picture, where no scrollbar
will go. In IE, the left border of the left picture will stop
when touching the left side of the window, while the column
will remain centered.

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 20 '05 #5
Abs wrote:
Ok, I'll try with no DIVs surrounding the images.


I don't know if the text-align hack is the right way to do it.


IMG is inline by default, and text-align is for inline content, so it
is the right way to do it, and is not a "hack".

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #6

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

Similar topics

18
by: Heath | last post by:
Is it proper to center images in a <div> by using the text-align: center property? Or is there a better way?
5
by: Robert J. O'Hara | last post by:
For some time I've made use of the max-width property in CSS to cause my pages to appear as a centered block against a contrasting background. This works well in new browsers (Mozilla, etc.) and...
3
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...
3
by: rsteph | last post by:
I'm using two divs to create a shadowed-box type effect. Within the top div I want to put an image. I can get the image to center right to left, but not top to bottom. I'm making a series of boxes,...
3
by: BT | last post by:
I have taken over the support of an existing webpage and I need to revise the page so that it is centered (left and right) on the screen instead of aligned on the left. I can do this easily, but...
2
by: rudicheow | last post by:
SHORT VERSION ============= I have a bunch of identical fixed-size single-celled tables that rest against each other horizontally thanks to "float:left". These tables are dynamically generated...
2
by: tonsi | last post by:
I have a page but it wont center the div. Can anyone take a look at it and help. When I try to center in the body using text-align: center; it doesn't work with the main container (called Table_01)....
14
by: issentia | last post by:
I'm working on this site: http://www.essenceofsoy.com/redesign/index2.html and I'm having a few problems with getting the layout exactly right. 1) When the menu items are rolled over, they...
1
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...
4
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.