View Single Post
Old 01-22-2015, 05:54 AM   #6
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,799
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Doctor T View Post
Hi!

Is there a problem if I use ...

<p class="center"><img src="../Images/Tbl_1_1.jpg" /></p>

... for centering images?

FYI, i use ...

p.center {text-align: center;}

... in the style sheet.

Thank you!

Dr. T
That won't work because the property "text-align: center;" only works for inline elements and an image is a block element. So you have two ways to center horizontally an image:

1. To use:

Code:
.center {
     width: X%; /* Where X is the width you wish */
     margin-left: auto;
     margin-right: auto;
}
And in the .xhtml file:

Code:
<p class="center"><img alt="" src="../Images/Tbl_1_1.jpg" /></p>
Note: now "margin-left: auto" and "margin-right: auto" work in ADE 4.0 (for that reason I'm using them).

2. To use:

Code:
.center { 
      text-align: center;
      text-indent: 0;
}

.inlined {
     display: inline;
}
And in the .xhtml file:

Code:
<p class="center"><img class="inlined" alt="" src="../Images/Tbl_1_1.jpg" /></p>
Both methods will center your image.

Regards
Rubén
RbnJrg is offline   Reply With Quote