【问题标题】:Labels, text area, and button not positioning properly标签、文本区域和按钮定位不正确
【发布时间】:2016-03-30 20:09:10
【问题描述】:

我正在尝试调整我的代码以将反馈标签放置在右侧,文本区域位于右侧,底部的按钮居中。我无法让它们正确对齐,并为此苦苦挣扎了一段时间,现在需要一些帮助:

HTML

 <div class = "formBkg">
<br></br>
<label class = "lbl">First Name: <b class = "red">*</b></label><input class = "inp" type = "text" name = "fName" placeholder = "Adam">
<label class = "form">Feedback about the site: <b class = "red">*</b></label>
<textarea class = "area"rows = "5" cols = "50" name = "feedback" placeholder="Enter your comments..."></textarea>


<p><label class = "lbl">Surname: </label><input class = "inp" type = "text" name = "sName" placeholder = "Richardson"></p>
<p><label class = "lbl">Email: </label><input class = "inp" type = "email" name = "eMail" placeholder = "gqfc1@hotmail.com"></p>

<p><label class = "lbl">Rate the website: <b class = "red">*</b></label></p>
<input type = "radio" name = "rating" value = "terrible"> Terrible
<input type = "radio" name = "rating" value = "poor"> Poor
<input type = "radio" name = "rating" value = "adequate"> Adequate
<input type = "radio" name = "rating" value = "good"> Good
<input type = "radio" name = "rating" value = "excellent"> Excellent
<p><input type = "button" name = "input" value = "Submit" class = "btn"></p>
</div>

</form>

CSS

.red{
    color: #ff0000;
}
.inp{
    padding: 5px 0 5px 5px;
}

.lbl{
    padding: 0 20px 0 150px;
    padding-right:20px;
    font-weight: bold;
    font-size: 20px;
    width: 220px;
    float:left;
}
.formBkg{
    background-color: #696969;
    color: #ffffff;
    padding: 20px 0 20px 0;
}
.form{
    padding: 0 700px 0 20px;
    font-weight: bold;
    font-size: 20px;
    width: 220px;
    float:right;
}
.area{
    float:center;
}

.btn{
    text-align: center;
}

【问题讨论】:

  • 你能发一张你的目标和你得到什么的截图吗?
  • tinypic.com/r/2uz4d5g/9 抱歉,我在外地工作,我的设备出了点问题……但大致就是这样……

标签: html css button label textarea


【解决方案1】:

将高度设置为&lt;textarea&gt;,将相同的行高设置为&lt;label&gt;

CSS

.area{
  height:100px;
}
.form{
  line-height:100px;
}

这将使标签在中心垂直对齐

【讨论】:

    猜你喜欢
    • 2019-08-21
    • 2013-03-21
    • 2011-08-11
    • 2017-12-05
    • 1970-01-01
    • 2017-12-03
    • 1970-01-01
    • 1970-01-01
    • 2016-10-30
    相关资源
    最近更新 更多