使用 HTML/CSS 使所有三个 3 HTML 链接显示在同一行?

发布于 2024-12-14 03:55:33 字数 529 浏览 4 评论 0原文

我有以下 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纵情客 2024-12-21 03:55:33

display:inline;display:inline-block 添加到表单元素。例如:

<form style="display:inline">

小提琴:http://jsfiddle.net/gJqvr/1/

Add display:inline; or display:inline-block to your form element. Eg:

<form style="display:inline">

Fiddle: http://jsfiddle.net/gJqvr/1/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文