Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

align picture within field set

Status
Not open for further replies.

thelearners

Programmer
Jul 1, 2004
8
US
Hi,

I'm want to center my picture inside the <fieldset>, how do I modify my codes here?

<fieldset style="width:300;height:400; border: solid
3px red" align="center">
<legend align="center">
My Picture
</legend>
<img src="love.gif" width="120" height="120">
</fieldset>

Thanks in advance
 
maybe <center> image </center> ?

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 

I've not tried this, but worth a go anyhow:

Code:
<img src="love.gif" width="120" height="120" style="margin:0px auto 0px auto;">

Hope this helps,
Dan
 
Perhaps:
Code:
<fieldset style="width:300;height:400; border: solid 3px red; [COLOR=red]text-align: center[/color]">
   <legend>My Picture</legend>
   <img src="love.gif"  width="120" height="120">
</fieldset>

<marc> i wonder what will happen if i press this...[ul][li]please tell us if our suggestion has helped[/li][li]need some help? faq581-3339[/li][/ul]
 
Hi all,

I triey all the suggestions.Only with this <fieldset style="width:300;height:400; border: solid 3px red; text-align: center"> that my picture is centered. However it's only center from left to right but not from top to bottom. I want it to be cetered right in the middle of my border.

Thanks
 
I can't be sure this'll work - it's affected by whatevery else is in the fieldset and the other styles applied....
Code:
<fieldset style="width:300;height:400; border: solid 3px red; [COLOR=red]text-align: center; [b]vertical-align: middle;[/b][/color]">

<marc> i wonder what will happen if i press this...[ul][li]please tell us if our suggestion has helped[/li][li]need some help? faq581-3339[/li][/ul]
 
I've always found that the best way to align anything is with a table, and since fieldsets can contain tables, I'd remove the height/width from the style of fieldset, and assign it to an embedded table. This give the table the proper height/width for the valign and align or the tr and td to center your image directly in the middle.
Try ...

Code:
<fieldset style="border: solid 3px red" align="center">
  <legend align="center">
    My Picture  
  </legend>
  <table border="0" cellpadding="0" cellspacing="0" width="300" height="400">
    <tr valign="center">
      <td align="center"><img src="love.gif"  width="120" height="120"></td>
    </tr>
  </table>
</fieldset>

I'm a lazy programmer, so the code's not tested ... but it should put you on the right track ... good luck :)
 
Hi XTC269,

It works now with some minor change. I have to change the
width to 100% and then it center just the way I want
(verticlely and horizontally).

<table border="0" cellpadding="0" cellspacing="0" width="100%" height="400">

Thank you very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top