如何对齐多个表单元素?
我对设计一无所知,我正在尝试让一个简单的 HTML 表单看起来像这样: 。
基本上,它是一个具有三个 输入字段和一个 提交按钮的表单。
关于输入字段,有两个在上面和一个在下面。我希望它们彼此完全中心对齐,并且第二个拉伸到与上面的宽度相同。
关于提交按钮,我希望它与输入字段在水平和垂直方向上完全居中对齐,但位于这些字段的右侧。
我不太担心它不能完全跨浏览器。
感谢您的指点!
编辑:我更喜欢使用 CSS 完成而不是基于表格。 (我听说基于表格的做法简直就是邪恶。)
I've no clue at design, and I'm trying to get a simple HTML form to look like this:
.
Basically, it's a form with three input fields and one submit button.
Regarding the input fields, there are two on top and one below. I'd like these to be perfectly centre-aligned with each other and the second one to stretch to be the same width as the ones above.
Regarding the submit button, I'd like it to be perfectly center-aligned, both horizontally and vertically, with the input fields, but be to the right of these.
I'm not too worried about it not being fully cross-browser.
Thanks for any pointers!
Edit: I'd prefer if it were done with CSS rather than be table-based. (I hear table-based is just plain evil.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以用一张桌子。 :) 这是为您准备好的代码:
You could use a table. :) Here's the code ALL ready for ya:
用纯 CSS 来做这样的事情怎么样?顺便说一句......您知道有关输入字段和搜索按钮的具体尺寸吗?如果我知道一些尺寸,我可能可以做得更干净一些。不管怎样,看看演示...
http://jsfiddle.net/zxSFp/1/
HTML
CSS
我希望这有帮助。
How about something like this with pure CSS? By the way... do you know specific dimensions regarding your input fields and the search button? I could probably do this a little cleaner if I knew some dimensions. Anyway, check out the demo...
http://jsfiddle.net/zxSFp/1/
HTML
CSS
I hope this helps.