简体   繁体   English

html表单内容和css对齐问题

[英]html form content and css alignment issues

I have a user registration form with a submit button and a cancel button, 我有一个带有注册按钮和取消按钮的用户注册表格,

Problem 1) I can't have those two buttons inside the single form, if I have the cancel button inside the form with submit button , when I click the cancel button , it execute the action of the form instead of going to home and cancelling the registration page. 问题1)我不能在单个表单中拥有这两个按钮,如果我在带有submit button的表单中具有取消submit button ,当我单击“ cancel button ,它将执行表单的动作,而不是回家并取消注册页面。

Can't we have these two buttons inside a single form..? 我们不能在一个表单中包含这两个按钮吗?

Problem 2) Because of Problem 1, I added the cancel button outside the form and linking to the home page, it works as I expect, but, I need to have those two button in the same row on the screen. 问题2)由于问题1,我在表单外部添加了“ cancel button并链接到主页,该cancel button按我的预期工作,但是,我需要在屏幕的同一行中放置这两个button

<div id="main-content">
    <div id="login-container">
        <form id="user-registration-form" method="POST">
            // Some other fields, like username, etc.
            <fieldset class="edit" id="submit-button-fieldset">

                <input type="submit" id="submit-regiser"/>

            </fieldset>

        </form>
        <fieldset id="Cancel-field">
          <button id='cancel-registration' onclick=window.location.href='link-to-home'>Cancel</button>
        </fieldset>
      </div>
  </div>

I need to have those #submit-regiser and #cancel-registration in the same row in the screen. 我需要在屏幕的同一行中包含#submit-regiser#cancel-registration And this is for mobile browser, so should obey XHTML rules 这是针对移动浏览器的,因此应遵守XHTML规则

Thanks in advanced. 提前致谢。

That's the intended behavior. 这是预期的行为。 Cancel buttons are supposed to clear the form, not to take one back to what page ever. 取消按钮应该清除表格,而不是退回到任何页面。

Still you can do it this way using the <button> element: 您仍然可以使用<button>元素以这种方式进行操作:

<form id="user-registration-form" method="POST">
    <fieldset class="edit" id="submit-button-fieldset">
        <button type="submit" id="submit-regiser">submit</button>
        <button id="cancel-regiser" onClick="window.location.href='http://example.com'; return false;">Back</button>
    </fieldset>
</form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM