2011-05-06 4 views
0

방금 ​​MVC3을 사용하기 시작했습니다. 이 HTMLMVC3의 입력 필드 너비

<div class="editor-field"> 
        <input disabled="disabled" id="Status_RowKey" name="Status.RowKey" readonly="readonly" type="text" value="0001" /> 
      </div> 

를 생성

<div class="editor-field"> 
        @Html.TextBoxFor(model => model.Status.RowKey, new { disabled = "disabled", @readonly = "readonly" }) 
       </div> 

을하지만 모든 입력 필드가 약 160 픽셀입니다 같은 폭주의 사항 : I는 다음과 같이 필드를 사용하고 있습니다. 내가 그 (것)들을 더 넓게 할 수있는 방법이 있는가? 내 편집기 필드 클래스에서 나는

+0

가능한 중복을 추가하여

에 스타일을 추가 할 필요가 [HTML의 폭을 설정하는 방법에 대해 설명합니다. textboxfor?] (http://stackoverflow.com/questions/3575067/how-to-set-width-of-html-textboxfor) –

답변

2

당신은 크기 속성을 설정할 수 있습니다 :

@Html.TextBoxFor(model => model.Status.RowKey, new { size = 200, disabled = "disabled", @readonly = "readonly" }) 

처럼, CSS의 입력 폭을 설정하고 텍스트 상자를 클래스를 제공 할 것입니다 아마 더 적절한 :

@Html.TextBoxFor(model => model.Status.RowKey, new { @class = "myClass", disabled = "disabled", @readonly = "readonly" }) 

<style> 
    input.myClass { width = 200px; } 
</style> 
+0

감사합니다. 클래스를 사용하지 않고 첫 줄의 너비를 직접 설정할 수있는 방법이 있습니까? – JonWylie

+0

감사합니다. 방금 나도 그걸하는 법을 알았어. 위대한 작품 – JonWylie

1

CSS를 사용할 수 있습니다. 예를 들어

:

input#StatusRowKey /* matches only the textfield with id StatusRowKey */ 
{ 
    width: 250px; 
} 
input    /* matches all input types */ 
{ 
    width: 200px; 
} 
input.Normal /* matches all input fields with class="Normal" */ 
{ 
    width: 100px; 
} 
1

당신의 필드가없는 경우 모든 브라우저를 스타일링하는 것은 그들에 대한 자신의 기본 너비의 적용됩니다. 당신은

div.editor-field input { width: 300px; } 

또는 인라인으로

가 (시스템 권장되지 않음)가 포함 된 외부 CSS 파일의

@Html.TextBoxFor(model => model.Status.RowKey, new { disabled = "disabled", @readonly = "readonly", style="width:300px" })