2016-08-12 4 views
0

나는 내가 부트 스트랩의 최신 버전을 사용하는 면도기보기 두 열은

<div class="container"> 

<div class="row well"> 
    <div class="col-md-4 col-md-offset-4"> 
     <h2>Create</h2> 
     <h4>Create Advert</h4> 
    </div> 
</div> 

@using (Html.BeginForm()) 
{ 
    @Html.AntiForgeryToken() 

    <div class="form-horizontal"> 

     @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 

     <div class="text-danger">@ViewBag.Message</div> 
     <div class="row"> 
      <div class="col-md-1"></div> 
      <div class="col-md-5"> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.Title, htmlAttributes: new { @class = "control-label col-md-2 " }) 
        <div class="col-md-8"> 
         @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } }) 
         @Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.Country, htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.DropDownList("CountryDropDown", null, htmlAttributes: new { @class = "form-control", @id = "Country" }) 
         @Html.Hidden("Countries", null, htmlAttributes: new { @class = "form-control", @id = "HiddenCountry" }) 
         @Html.ValidationMessage("CountryDropDown", "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.Subregion, htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.EditorFor(model => model.Subregion, new { htmlAttributes = new { @class = "form-control" } }) 
         @Html.ValidationMessageFor(model => model.Subregion, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } }) 
         @Html.CheckBox("PriceCheck", isChecked: false) @Html.DisplayName("Price negotiable") 
         @Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.BuildingFloorsId, "Floors", htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.DropDownList("FloorsDropDown", null, htmlAttributes: new { @class = "form-control" }) 
         @Html.ValidationMessageFor(model => model.BuildingFloorsId, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.Area, htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.EditorFor(model => model.Area, new { htmlAttributes = new { @class = "form-control" } }) 
         @Html.ValidationMessageFor(model => model.Area, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.Label("TPP", htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.EditorFor(model => model.Area, new { htmlAttributes = new { @class = "form-control" } }) 
         @Html.ValidationMessageFor(model => model.Area, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.Label("Type of construction", htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.EditorFor(model => model.Interior, new { htmlAttributes = new { @class = "form-control" } }) 
         @Html.ValidationMessageFor(model => model.Interior, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.Exterior, htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.EditorFor(model => model.Exterior, new { htmlAttributes = new { @class = "form-control" } }) 
         @Html.ValidationMessageFor(model => model.Exterior, "", new { @class = "text-danger" }) 
        </div> 
       </div> 
      </div> 

      <div class="col-md-5"> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.AdvertisementCategoryId, "Category", htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.DropDownList("AdvertisementCategoryId", null, htmlAttributes: new { @class = "form-control", @id = "ddlProductCategory" }) 
         @Html.ValidationMessageFor(model => model.AdvertisementCategoryId, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.State, htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.DropDownList("StateDropDown", null, htmlAttributes: new { @class = "form-control", @id = "State" }) 
         @Html.Hidden("States", null, htmlAttributes: new { @class = "form-control", @id = "HiddenState" }) 
         @Html.ValidationMessage("StateDropDown", "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.Address, htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.EditorFor(model => model.Address, new { htmlAttributes = new { @class = "form-control" } }) 
         @Html.ValidationMessageFor(model => model.Address, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.Label("Currency", htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.DropDownList("Currency", null, htmlAttributes: new { @class = "form-control", @id = "Currency" }) 
         @Html.Hidden("Currencies", null, htmlAttributes: new { @class = "form-control", @id = "HiddenCurrency" }) 
         @Html.ValidationMessage("Currency", "", new { @class = "text-danger" }) 
        </div> 
       </div> 
       <br> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.FloorId, "Floor", htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.DropDownList("FloorDropDown", null, htmlAttributes: new { @class = "form-control" }) 
         @Html.ValidationMessageFor(model => model.FloorId, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.TelephonNum, htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.EditorFor(model => model.TelephonNum, new { htmlAttributes = new { @class = "form-control", @id = "TelNum" } }) 
         @Html.ValidationMessageFor(model => model.TelephonNum, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.RoomsNumber, htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.EditorFor(model => model.RoomsNumber, new { htmlAttributes = new { @class = "form-control" } }) 
         @Html.ValidationMessageFor(model => model.RoomsNumber, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control" } }) 
         @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" }) 
        </div> 
       </div> 

       <div class="form-group"> 
        @Html.LabelFor(model => model.Interior, htmlAttributes: new { @class = "control-label col-md-2" }) 
        <div class="col-md-10"> 
         @Html.EditorFor(model => model.Interior, new { htmlAttributes = new { @class = "form-control" } }) 
         @Html.ValidationMessageFor(model => model.Interior, "", new { @class = "text-danger" }) 
        </div> 
       </div> 
      </div> 
      <div class="col-md-1"></div> 
     </div> 

     <div class="row"> 
      <div class="col-md-4 col-md-offset-4"> 

       <div class="form-group"> 
        <img src="@Url.Action("GetCaptchaImage","Captcha")" style="width:300px;" /> 
       </div> 

       <div class="form-group"> 
        @Html.Label("Enter Code", new { @class = "col-md-2 control-label" }) 
        <div class="col-md-10"> 
         @Html.TextBox("CaptchaText", "", new { @class = "form-control" }) 
        </div> 
       </div> 
      </div> 
     </div> 

     <div class="row"> 
      <div class="form-group"> 
       <div class="col-md-4 col-md-offset-4"> 
        <input type="submit" value="Create" class="btn btn-default" style="width:300px;" /> 
       </div> 
      </div> 
     </div> 

    </div> 
} 
을 다음했다. 이 코드를 실행하면 결과가 좋지 않습니다. enter image description here 열과 행이 중앙에 있지 않습니다. 레이블이있는 입력 필드는 블록 요소이며 클래스 이름은 "텍스트 센터"가 작동하지 않습니다. 나는 "블록 중심"으로 시도했지만 아무것도하지 않았다. 나는 또한 상쇄를 시도했다. 아이디어가 있다면 큰 일이 될 것입니다.

+0

는 당신이 우리 당신을 보여줄 수 있어요 출력 HTML은 우리가 수정할 수있는 것을보다 잘 표현한 것입니다. 바로''.row'와'.well'을 결합하는 것과 같은 Bootstrap 프레임웍 문제를보고 있습니다.'.row' 나'.col - * - * '내부에 폼 자체가 없기 때문에 아마도 올바르게 센터링하지 않습니다 ... 등 –

답변

1

특정 부트 스트랩 스타일을 결합하는 방법이 프레임 워크 사용 방법과 충돌합니다. 그리드 요소는 (그들에 부착 된 디자인 구성 요소가해서는 안 즉. class="row well" 디자인 요소 그리드의 흐름을 방해 할 수있는 추가 마진과 패딩을 추가한다.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> 
 
<div class="container-fluid"> 
 
    <div class="row"> 
 
    <div class="col-md-12"> 
 
      
 
      <div class="well text-center"> 
 
     <h2>Create</h2> 
 
      <h4>Create Advert</h4> 
 
      </div> 
 
      
 
     </div> 
 
    </div> 
 
    
 
    <div class="row"> 
 
     <form class="form-horizontal"> 
 
     
 
<div class="col-xs-6"> 
 
    <div class="form-group"> 
 
    <label for="" class="control-label col-xs-2">Label</label> 
 
    <div class="col-xs-10"> 
 
     <input type="text" name="" class="form-control"> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="col-xs-6"> 
 
    <div class="form-group"> 
 
    <label for="" class="control-label col-xs-2">Label</label> 
 
    <div class="col-xs-10"> 
 
     <input type="text" name="" class="form-control"> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="col-xs-6"> 
 
    <div class="form-group"> 
 
    <label for="" class="control-label col-xs-2">Label</label> 
 
    <div class="col-xs-10"> 
 
     <select name="" class="form-control"></select> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="col-xs-6"> 
 
    <div class="form-group"> 
 
    <label for="" class="control-label col-xs-2">Label</label> 
 
    <div class="col-xs-10"> 
 
     <select name="" class="form-control"></select> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="col-xs-6"> 
 
    <div class="form-group"> 
 
    <label for="" class="control-label col-xs-2">Label</label> 
 
    <div class="col-xs-10"> 
 
     <input type="text" name="" class="form-control"> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="col-xs-6"> 
 
    <div class="form-group"> 
 
    <label for="" class="control-label col-xs-2">Label</label> 
 
    <div class="col-xs-10"> 
 
     <input type="text" name="" class="form-control"> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="col-xs-6"> 
 
    <div class="form-group"> 
 
    <label for="" class="control-label col-xs-2">Label</label> 
 
    <div class="col-xs-10"> 
 
     <select name="" class="form-control"></select> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="col-xs-6"> 
 
    <div class="form-group"> 
 
    <label for="" class="control-label col-xs-2">Label</label> 
 
    <div class="col-xs-10"> 
 
     <select name="" class="form-control"></select> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="col-xs-6"> 
 
    <div class="form-group"> 
 
    <label for="" class="control-label col-xs-2">Label</label> 
 
    <div class="col-xs-10"> 
 
     <input type="text" name="" class="form-control"> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="col-xs-6"> 
 
    <div class="form-group"> 
 
    <label for="" class="control-label col-xs-2">Label</label> 
 
    <div class="col-xs-10"> 
 
     <input type="text" name="" class="form-control"> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="col-xs-6"> 
 
    <div class="form-group"> 
 
    <label for="" class="control-label col-xs-2">Label</label> 
 
    <div class="col-xs-10"> 
 
     <select name="" class="form-control"></select> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<div class="col-xs-6"> 
 
    <div class="form-group"> 
 
    <label for="" class="control-label col-xs-2">Label</label> 
 
    <div class="col-xs-10"> 
 
     <select name="" class="form-control"></select> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
      
 
    </form> 
 
    </div> 
 
    
 
</div>

를 양식 구조에서 그 불일치의 결과를 수정 Bootstrap의 <label>에는 더 긴 레이블에 문제가 있다는 점에 유의해야하지만 (레이블은 단순히 부적절한 방식으로 확장됩니다).

+0

빠른 답변 감사합니다! 그러나 col-xs-6을 모두 집중시키는 방법은 무엇입니까? –

+0

'.container '가 화면의 100 %를 차지하지 않게하려면, 대신에 .container-fluid를 사용하십시오. 그러면 화면 중앙에 배치됩니다. –

+0

모든 입력 및 레이블을 중앙에 배치하고 싶습니다. 이제 왼쪽에 있기 때문입니다. –

1

나는이 부분이 causin g 문제 클래스 = "COL-MD-4 COL-MD-오프셋 4"이 같은

뭔가 확실히 작동합니다 :

여기
<div class="container"> 

    <div class="row well"> 
    <div class="text-center"> 
     <h2>Create</h2> 
     <h4>Create Advert</h4> 
    </div> 
    </div> 

    <div class="form-horizontal"> 
    <div class="text-danger"></div> 
    <div class="row"> 

     <div class="col-xs-6"> 
     <div class="form-group"> 
      <label for="inputEmail3" class="col-sm-2 control-label">Email</label> 
      <div class="col-sm-10"> 
      <input type="email" class="form-control" id="inputEmail3" placeholder="Email"> 
      </div> 
     </div> 
     </div> 

     <div class="col-xs-6"> 
     <div class="form-group"> 
      <label for="inputPassword3" class="col-sm-2 control-label">Password</label> 
      <div class="col-sm-10"> 
      <input type="password" class="form-control" id="inputPassword3" placeholder="Password"> 
      </div> 
     </div> 
     </div> 

    </div> 
    </div> 

JSFiddle