Solved

formatting picture in table so it is centered

Posted on 2013-01-14
11
183 Views
Last Modified: 2013-02-15
I have a table that I am using for configuring the footer of a webpage.  In the first line of the table data I want to center a company logo.   For the second line I want two flags for the two companies we do business in (centered in the row but beside each other.

When I try it out it seems to just float to the left.

Anyone know what I am doing wrong ,  beloe is example of the logo bit.

<table border='1' cellspacing="0">
                                    <tbody>
                                          <tr>
                                                <td style="text-align:center">
                                                      <img src="/images/logo.png" alt="Footer Logo" border="0" height="18" width="75">
                                                </td>
                                          </tr>
                                          
                                    </tbody>
                              </table>
0
Comment
Question by:enigma1234567890
11 Comments
 
LVL 9

Assisted Solution

by:TazDevil1674
TazDevil1674 earned 100 total points
ID: 38774353
Try this instead

<td>
  <p style:text-align:center;><img src="/images/logo.png" alt="Footer Logo" border="0" height="18" width="75">
  </p>
</td>

Open in new window

0
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 400 total points
ID: 38774394
Change your table

<table border='1' cellspacing="0" width="100%">
                                    <tbody>
                                          <tr>
                                                <td style="text-align:center">
                                                      <img src="/images/logo.png" alt="Footer Logo" border="0" height="18" width="75">
                                                </td>
                                          </tr>
                                         
                                    </tbody>
                              </table>
0
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 400 total points
ID: 38774402
If this is your only thing in your footer, why are you using a table?

If your footer is set with divs just do this

css:
#footer {text-align:center;}

HTML:

<div id="footer>
        <img src="/images/logo.png" alt="Footer Logo" border="0" height="18" width="75">
</div>
0
 

Author Comment

by:enigma1234567890
ID: 38774480
still stuck none of the suggestions for tables worked.

Note its not the only think in table so I dont want to use divs.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 38774512
The code I gave you works fine.  sample.

 If it is not working in your layout, it is because something else is controlling it.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 38774524
Try adding   a class to the td <td class="center" style="text-align:center"> and css  td.center{text-align:center;}
0
 

Author Comment

by:enigma1234567890
ID: 38774553
I tried padding:auto and that centered the logo but when I add the next row with the two flags its messed up again.

Any other suggestions.
0
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 400 total points
ID: 38774728
It would not be padding auto - if anything it would be margin auto.  However, to center an image you use text-align:center in css.

Here I tried a table in a table like you are probably using and make the footer td of the outer table left align.
 
Using my original code, the image is still centered. Please click this sample to see.  

<table border='1' cellspacing="0" width="100%">
  <tr><td>stuff</td></tr>
  <tr><td align="left">
    <!-- add footer below-->
    <table border='1' cellspacing="0" width="100%">
                                    <tbody>
                                          <tr>
                                                <td class="center" style="text-align:center">
                                                  <img src="" alt="Footer Logo" border="0" height="18" width="75" style="background-color:red">
                                                </td>
                                          </tr>
                                          
                                    </tbody>
                              </table>
    <!-- end footer above-->
   </td></tr>
  
</table>  

Open in new window


If this is not working for you, please post a shortened version of your code with  css.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38775361
Just post the link and we can look at the whole picture at once instead of trying to peel an onion.

Cd&
0
 

Author Comment

by:enigma1234567890
ID: 38775676
sorry test site not on internet
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 400 total points
ID: 38775743
Can you please copy/paste  your html code to http://jsbin.com/aqazut/1/edit.  If you have external css, make sure to copy paste the css into the css area.    

otherwise, just copy paste your entire code here and make sure to include any links to javascript and css.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now