В настоящее время у меня есть:
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
в %
?