私は現在持っています:
jquery
$(document).ready(function () {
$('.span-fix').each(function(){ /* Do this for each extended input */
var wide = $(this).width(), /* create a variable that holds the width of the form */
label = $(this).prev('.add-on').width(); /* create another variable that holds the width of the previous label */
$(this).width( wide - label ); /* subtract the label width from the input width and apply it in px */
});
});
html
<div class="input-prepend">
<span class="add-on">Location</span>
<input name="ctl00$ContentPlaceHolder1$tbLocation" type="text" id="tbLocation" class="span12 span-fix" placeholder="Location" style="width: 97.04668304668304%; ">
</div>
問題を示すフィドル:http://jsfiddle.net/SuguM/
ただし、これはの新しい幅を適用しますpx
。流動的なレイアウトを使用しているため、これをパーセントにする必要があります。
px
適用されたものをに変換する方法はあり%
ますか?