<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - input field won't center after jquery replaceWith]]></title>
		<link>http://railsforum.com/viewtopic.php?id=44794</link>
		<description><![CDATA[The most recent posts in input field won't center after jquery replaceWith.]]></description>
		<lastBuildDate>Fri, 29 Jul 2011 12:42:09 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[input field won't center after jquery replaceWith]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=142751#p142751</link>
			<description><![CDATA[<p>I feel a little out of place putting this here, but I&#039;m pretty new to all of this so please excuse my ignorance. So I&#039;ve got a form that an image is clicked on then is replaced with an input field. The jquery looks great, but I&#039;ve got the problem of styling it. The only real problem is trying to get it centered. I can do this via margin left, but when viewed on mobile devices, it&#039;s all messed up, so I realized centering it in the form div works great on the mobile devices, but not on the web browser for the computers.&nbsp; </p><p>Basically, I have the following code for the form name: </p><p>#name_img <br />#name_form&nbsp; &nbsp;<br />&nbsp; = f.text_field :name </p><p> Here&#039;s the css: </p><p>#name_img&nbsp; {&nbsp; &nbsp;<br />background-image:url(&#039;name.png&#039;);&nbsp; &nbsp;<br />width:202px;&nbsp; &nbsp;<br />height:48px;&nbsp; &nbsp;<br />margin:0px auto; <br />}&nbsp; </p><p>#name_form {&nbsp; &nbsp;<br />margin:0px auto; <br />}&nbsp; </p><p>The name img when clicked fades out and is replaced w/ the name input field &quot;#name_form&quot;. I figure it has to deal with the replaceWith not reading the #name_form when loading it.</p><p>Just for good measure here is the JS: (coffeescript)<br />$(&quot;#name_img&quot;).click -&gt;<br />&nbsp; &nbsp; $(this).fadeOut(&quot;slow&quot;).replaceWith $(&quot;#name_form&quot;)<br />&nbsp; &nbsp; $(&quot;#name_form&quot;).fadeIn &quot;slow&quot;</p><p>Again, all I&#039;m having problems with is centering the #name_form using margin: 0px auto;<br />Edit: To clarify, I can get it looking just fine on desktop browsers, the problem arises when using mobile browsers. It&#039;s only the form fields that get offset, and so when I use the margin auto, desktop browsers don&#039;t recognize, and mobile do.</p><p>Thank you for you&#039;re help in advance <img src="http://railsforum.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (jens0771)]]></author>
			<pubDate>Fri, 29 Jul 2011 12:42:09 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=142751#p142751</guid>
		</item>
	</channel>
</rss>
