473,385 Members | 1,748 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,385 software developers and data experts.

Center alignment for different image sizes

1
Hi Guys,

I have a huge problem. I'd like to put my images to the middle of a div. Every image has a different size (It would be a gallery).
I have tried several solutions, but none worked.

My biggest problem is the pictures have a shadow, so I have to take them and their shadow also in the middle.

Expand|Select|Wrap|Line Numbers
  1. css code:
  2.  
  3. body {
  4.     font-family: Arial, Helvetica, sans-serif;
  5.     font-size: 100%;
  6.     background-color: #000000;
  7.     margin: 0 auto;
  8.     padding: 0 0 0 0em;
  9. }
  10.  
  11. #container {
  12.     width: 801px;
  13.     height: 600px;
  14.     background-color: #FFFFFF;
  15.     border: 1px solid #9f9e9e;
  16.     margin:0 auto;
  17. }
  18.  
  19. #body {
  20.     width: 799px;
  21.     height: 460px;
  22.     margin: 1px 1px 1px 1px;
  23. }
  24.  
  25. #body_left {
  26.     width: 306px;
  27.     height: 458px;
  28.     background-image: url(../images/body_left.jpg);
  29.     border: 1px solid #9d9c9c;
  30.     float: left;
  31.     margin:0px 1px 0px 0px;
  32. }
  33.  
  34. #body_right {
  35.     width: 488px;
  36.     height: 458px;
  37.     background-color: #d5ded6;
  38.     border: 1px solid #9d9c9c;
  39.     float: left;    
  40.     margin:0px 0px 0px 0px;
  41. }
  42.  
  43. .img_wrapper {
  44.     background: url("../images/picture_background.gif") no-repeat bottom right;
  45.     float: left;   
  46. }
  47.  
  48. .img_wrapper img {   
  49.     background-color: #FFFFFF;
  50.     border: 1px solid #504e4e;
  51.     padding: 4px 4px 4px 4px;
  52.     margin: 0 auto;
  53.     position: relative;
  54.     right: 3px;
  55. }
  56.  
  57.  
  58. html code:
  59.  
  60. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  61. <html xmlns="http://www.w3.org/1999/xhtml">
  62. <head>
  63. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  64. <title>dora vorosmarty</title>
  65. <link href="css/stylessheet.css" rel="stylesheet" type="text/css" />
  66. </head>
  67.  
  68. <body>
  69.     <div id="container">
  70.         <div id="body">    
  71.             <div id="body_left">
  72.             </div>
  73.             <div id="body_right">
  74.                  <div class="img_wrapper">
  75.                     <img src="images/img01.jpg"  />
  76.                 </div>
  77.             </div>
  78.         </div>
  79.     </div>
  80. </body>
  81.  
Jun 26 '08 #1
2 2136
try

Expand|Select|Wrap|Line Numbers
  1. <p><img src="pic.jpg" align="center"/></p>
M
Jun 27 '08 #2
or in css use

#center-pic{
margin:auto 0;
}
Jun 27 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: steven | last post by:
Hi, I'm trying to center an image in a div, both horizontally and vertically. (Each div holds a thumbnail image.) Here's the HTML: <div class="thumb"> <div> <img src="tn_02-2022.jpg" />...
4
by: Shashi | last post by:
Can somebody explain how the byte alignment for structures work, taking the following example and considering: byte of 1 Byte word of 2 Bytes dword of 4 Bytes typedef struct { byte a; word...
5
by: Clint Olsen | last post by:
I did a Google about this, and I've seen this covered quite a few times - some leading to useful tricks with offsetof() to discern alignment and others using a big-union of intrinsic types to...
10
by: j0mbolar | last post by:
for any pointer to T, does a pointer to T have different or can have different alignment requirement than a pointer to pointer to T? if so, where is the exact wording in the standard that would...
17
by: puzzlecracker | last post by:
> 2) >>struct B >>{ >> int i; >>short int si; >> char c; >> char d; >> int j; >>};
2
by: rassuls | last post by:
Can anyone explain what is meant by alignment in data structure in C language. What happens internally by changing the align value. Thanks in advance. Russell
0
by: Al | last post by:
Hi, I would like to create a PictureBox that can adjust to any image sizes and show scrollbars when necessary to allow user to scroll to different part of image. I have tried to use Panel with...
1
by: Jose | last post by:
Please como center a datagrid header and the data justify to right? Thanks a lot
14
by: gaijinco | last post by:
I was a hobbist web coder for years but I had to sidestep for a while. Now I'm trying to return to it and I'm trying to clarify how am I supposed to do somethings with CSS v.s. HTML and I'm...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.