Quote:
Originally Posted by Doctor T
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