css - 将消息和提交按钮对齐到其他输入字段的右侧

标签 css input css-float

Live site.

我在设置联系表单样式时遇到了一个小问题。我希望消息字段和提交按钮位于所有其他输入字段的右侧,并沿顶部对齐。当我使用 clear:bothfloat:right 时,消息和提交按钮确实会移动,但它们远低于所有其他字段。 我该如何解决这个问题?

.contact_name {
    font-family: fanwood-webfont;
    margin-left: 60px;
    padding-bottom: 10px;
}

.contact_email {
    font-family: fanwood-webfont;
    margin-left: 60px;
    padding-bottom: 10px;
}

.contact_subject {
    font-family: fanwood-webfont;
    margin-left: 60px;
}

.contact_message {
    clear: both;
    float: right;
    font-family: fanwood-webfont;
}

.contact_button {
    clear: both;
    float: right;
}

&

<p class=contact_name>Name (required)<br />
[text* your-name]</p>

<p class=contact_email>Email (required)<br />
[email* your-email]</p>

<p class=contact_subject>Subject<br />
[text* your-subject]</p>

<p class=contact_message>Message<br />
[textarea* your-message]</p>

<p>[submit class:contact_button "Send"]</p>

最佳答案

我建议您创建两个 <div>元素,一个 left floated第二个right .

你需要float基本上是属性(property)。

基本示例:

​#left {
   width: 150px;
   height: 100px;
   background-color: #eeeeee;
   float: left;
}

​#right {
   width: 150px;
   height: 100px;
   background-color: #eeeeee;
   float: right;
}​

工作 example .

关于css - 将消息和提交按钮对齐到其他输入字段的右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11139055/

相关文章:

javascript - 只有当它有标题时才显示 img?

javascript - 转换被添加......无休止

Python 使用空格键从输入继续

CSS 文本换行应将 float 元素视为一列

css - 用左边的 div 填充剩余空间

html - 在 CSS : rails 4 + bootstrap 3 中使用 glyphicon 作为背景图片

html - 跨浏览器半粗体字体问题

c++ - C/C++ 的轻量级 OBJ 网格文件加载器?

python - 如何在 Python 脚本中接受管道输入和用户提示输入?

php - div 的 CSS 属性显示 :table-cell flickers