How do I set the width and height of a textarea using CSS?

前端 未结 6 372
夕颜
夕颜 2021-01-17 07:42

Here is my css:

.editor-field textarea {
    width : 400;
    height : 100px;
}

Here is the markup from my view:

        &l         


        
相关标签:
6条回答
  • 2021-01-17 08:17

    Code:

    @Html.TextAreaFor(m => m.Message, 30, 10, new { @class = "what" })
    
    0 讨论(0)
  • 2021-01-17 08:22

    You left off px:

    .editor-field textarea {
        width : 400px;
        height : 100px;
    }
    
    0 讨论(0)
  • 2021-01-17 08:23

    try to use TextAreaFor helper method and set cols and rows html property

    Sample

    @Html.TextAreaFor(model=>model.MyMultilineText, new {rows="6", cols="10"})
    

    I Hope this help. Regards.

    0 讨论(0)
  • 2021-01-17 08:26

    After some time searching for it, the best way is to use one of the overloads of the method TextAreaFor()

    @Html.TextAreaFor(model => model.Visit.BehavioralObservations, 10, 40, new { HtmlAttributes = new { } })
    

    The 10 is the number of rows, the 40 is the number of columns

    0 讨论(0)
  • 2021-01-17 08:27

    style can be specified in the link will

    @Html.TextAreaFor(model => model.values, new {style = "width: 700px; height:200px;"})

    0 讨论(0)
  • 2021-01-17 08:39

    ASP MVC default project has site.css with max-width:280 for textarea -- remove that and try something like this

    @Html.TextAreaFor(model => model.ComicText, new { style = "width: 700px; height:150px;" }) 
    
    0 讨论(0)
提交回复
热议问题