473,799 Members | 2,840 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

centering images

How do you center images within a <div- or any other element
for that matter? If I try

margin-left: 50%;

it's only the left hand side of the image that is on the
centerline, not the center of the image.

margin-left: 50%;
margin-right: 50%;

I thought this may do it, but still same problem.

--
Troy Piggins ,-O (o- O All your sigs are belong to us.
http://piggo.com/~troy O ) //\ O
RLU#415538 `-O V_/_ OOO
hackerkey://v3sw5HPUhw5ln4p r6OSck1ma9u6LwX m5l6Di2e6t5MGSR b8OTen4g7OPa3Xs 7MIr8p7
Dec 21 '06 #1
3 1640
Troy Piggins wrote:
How do you center images within a <div- or any other element
for that matter?
http://www.google.com/search?q=how%2...%20CSS&num=100

--
Berg
Dec 21 '06 #2
* Bergamot wrote:
Troy Piggins wrote:
>How do you center images within a <div- or any other element
for that matter?

http://www.google.com/search?q=how%2...%20CSS&num=100
Thanks.

--
Troy Piggins ,-O (o- O All your sigs are belong to us.
http://piggo.com/~troy O ) //\ O
RLU#415538 `-O V_/_ OOO
hackerkey://v3sw5HPUhw5ln4p r6OSck1ma9u6LwX m5l6Di2e6t5MGSR b8OTen4g7OPa3Xs 7MIr8p7
Dec 22 '06 #3
Troy Piggins wrote :
How do you center images within a <div- or any other element
for that matter?

Interactive demo on CSS horizontal alignment and horizontal formating
CSS Horizontal alignment:
when to use margin-left, margin-right and when to use text-align
http://www.gtalbot.org/NvuSection/Nv...Alignment.html

If I try
>
margin-left: 50%;
Margin use will align accordingly a block-level element within its
containing parent; it will not align its inline element children. You
need to use text-align for this.

it's only the left hand side of the image that is on the
centerline, not the center of the image.

margin-left: 50%;
margin-right: 50%;

I thought this may do it, but still same problem.

"The [text-align] property describes how text (and inline elements) is
aligned within the element."
CSS 1 text-align property
http://www.w3.org/TR/CSS1#text-align

Gérard
--
remove blah to email me
Dec 22 '06 #4

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

Similar topics

18
4217
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
2650
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 falls back fine in IE6 and lesser creations. As one who practices "classic" (i.e. dull) typography, this has always been satisfactory since I've always used one-column pages. I'm now trying a two column layout so I can include a sidebar, and am...
3
4213
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>
3
7854
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, and the images in them aren't all the same size. So I've sized the boxes to mach the largest of them, and I want to center them, so those that are smaller will be in the middle of the first div. Here's the code on the page: <table border="0"...
3
3666
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 there is a little JavaScript that doesn't work correctly after I center it. I have tried to realign the page with either <centertag or align="left" attribute, but the pictures displayed with the JavaScript get messed up with everything I've...
2
3064
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 and the number of them can vary greatly. They are all contained within a parent table cell, which is centred on the page. But I am unable to find a way of centering these table cells within the parent cell.
2
2232
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). Please help! I would be ever so greatful. The page is located here: http://www.cpiequipment.com/test_site/index.html Here is the code: <html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
14
2529
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 cannot be clicked as links unless the mouse pointer is below the word. This happens in both Firefox and IE6. 2) In Firefox, the pink quote banner and two gray form boxes above and below the content aren't centered in the "content" div, and I can't...
1
2288
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
5288
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
9687
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
10482
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...
0
10251
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10225
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
10027
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
9072
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...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.