使用 HTML/CSS 使所有三个 3 HTML 链接显示在同一行?
我有以下 HTML(删除了一些表单输入标签,以使代码最小化以提高可读性):
<a href="add.html">Add</a> <a href="remove.html">Remove</a>
<form action="">
<a href="" onclick="parentNode.submit();return false;">Submit</a>
</form>
它基本上是三个链接,最后一个链接是一个模仿表单提交按钮功能的链接(我希望它作为一个链接,并且似乎唯一的跨浏览器方式就是使用带有 JavaScript 的链接 - 尽管我知道这需要启用 JavaScript)。
这可能是某些人的第二天性,但我似乎无法在同一行上获得彼此相邻的三个链接,它最终会在下一行上显示最后一个链接(我相信这是因为最后一个链接被包装在表单标签?)。
有没有办法通过将它们包装在带有某种 CSS 类的 div 中来解决这个问题(只是一个想法)?
I have the following HTML (removed some of the form input tags to make the code minimal for readability):
<a href="add.html">Add</a> <a href="remove.html">Remove</a>
<form action="">
<a href="" onclick="parentNode.submit();return false;">Submit</a>
</form>
Its basically three links, the last link is a link which mimics the functionality of a form submit button (I wanted it as a link and appears the only cross-browser way was with justing using a link with JavaScript - although I understand it would require JavaScript to be enabled).
This is probably second nature to some but I can't seem to get the three links on the same line next to each other, it ends up displaying the the last link on the next line (I believe its because the last link is wrapped in form tags?).
Is there a way to solve this by perhaps wrapping them in a div with a CSS class of some sort (just an idea)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
display:inline;
或display:inline-block
添加到表单元素。例如:小提琴:http://jsfiddle.net/gJqvr/1/
Add
display:inline;
ordisplay:inline-block
to your form element. Eg:Fiddle: http://jsfiddle.net/gJqvr/1/