Aligning entire contents of a div to the right side using css. (i.e. align object, image or input field)

17,200
<div id="container" style="width:500px;">
  <div id="text" style="width:250px; float:left;">Text</div>
  <div id="image" style="width:250px; float:left;">Image</div>
  <div id="input" style="width:500px; float:left; text-align:right">Input</div>
</div>
Share:
17,200
user256410
Author by

user256410

Updated on November 19, 2022

Comments

  • user256410
    user256410 over 1 year

    OK, DUE TO BEING NEW I WASNT ALLOWED TO POST IMAGES, SO I HAVE ATTACHED LINKS INSTEAD. (images should be inline with this question)

    Im writing a webpage and have a div containing some text (inline) an then an image. Now when one clicks on the image, a hidden div appears below with an input field. The input field in this div is automatically aligned to the left edge of the div. I want it aligned to the right of the div.

    As pictures speak louder than words, see link below.

    http://www.freeimagehosting.net/uploads/d827ecc330.png

    Anyhow the closest I got to a solution was to apply direction: rtl to hidden div, but then my text in my input field also changes to rtl.

    I just want the placing of the text field to be rtl, not the input.

    I hope this isnt too confusing.

    Im quite new to css but have searched arund a lot, and have yet to find a solution besides the depreciated align=right.

    Any suggestions greatly appreciated.

    • Dietrich Epp
      Dietrich Epp about 14 years
      This is a programming forum. Consider asking the question on doctype.com.
  • Erik
    Erik about 14 years
    I think you mean to have ; after each width declaration
  • user256410
    user256410 about 14 years
    Is there anyway to do this without specifying the widths? Like an equivalent of direction: RTL. without text inputs going rtl
  • user256410
    user256410 about 14 years
    Okay text-align right will do it, for input fields, possibly images aswell. Had read in many places that text align: right would not work except for text. Ooops,should have checked first.