简体   繁体   English

如何使不同形式的按钮彼此相邻?

[英]How to make buttons from different form to be next to each other?

Firstly, I'm using materialize for this.I'm making two buttons, one for sign in and one for sign up, both are in different forms i made it that way so the sign up button will direct to the register page without being prevented by the required attribute, the problem is, because both buttons come from different form somehow they wont be next to each other and i don't know why is that, i need both to be next to each other (the sign up button to be next to the sign in button)首先,我为此使用materialize。我正在制作两个按钮,一个用于登录,一个用于注册,两者都在不同的forms中,我这样做了,所以注册按钮将直接指向注册页面而不是由 required 属性阻止,问题是,因为两个按钮来自不同的形式,它们不会彼此相邻,我不知道为什么,我需要两个按钮彼此相邻(注册按钮在登录按钮旁边)

<!DOCTYPE html>
<html>
<head>
    <title>Sanrio Merch</title>
    <link rel="stylesheet" type="text/css" href="css/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <meta  name="viewport" content="width=device-width,initial-scale=1.0"/>
    <style type="text/css">
        body{
            background-image: url("assets/bg.gif");
            background-size: 100% 120vh;
            background-repeat: no-repeat;
            }
        .card{
            background: rgba(0,0,0,.4);
            width: 40%;
            height: 75vh;
            margin: 9% auto;
            }
        label,input{
            color: white;
            font-size: 1em;
        }
        input{
            border-bottom: 1px solid white !important;
        }
        input:focus{
            box-shadow: 0 1px 0 0 white !important;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="card">
            <form action="login.php" method="post">
            <div class="card-action white-text brown">
            <h3>SIGN IN</h3>
            </div>
            <div class="card-content">
              <div class="form-field">
              <label for="username">Username</label>
              <input type="text" id="username" name="username" placeholder="username" required="">
              <br><br>
              <label for="password">Password</label>
              <input type="password" id="password" name="pass" placeholder="password" required="">
              </div><br>
              </div><br><br>
              <div class="form-field center-align">
              <button class="btn-large brown" name ='sigin'style="margin-right: 2%;" type="submit" name="submit">Sign In</button>
              </div>
            </form>
            <form action="login.php" method="post">
            <button class="btn-large brown" name="register">Sign Up</button>
            </form>
        </div>
        </div>
    </div>
</body>
</html>

I expect the sign up button to be next to the sign in button but it doesnt display that way我希望注册按钮位于登录按钮旁边,但它不会那样显示在此处输入图像描述

You can create 2 buttons without the type="submit" and add some jQuery like so:您可以创建 2 个不带 type="submit" 的按钮并添加一些 jQuery ,如下所示:

$( "#button_sign_up" ).click(function() {
  $( "#form_sign_up" ).submit();
});

$( "#button_sign_in" ).click(function() {
  $( "#form_sign_in" ).submit();
});

This way you mark your button to perform a submit based on an form ID.这样,您可以标记您的按钮以根据表单 ID 执行提交。 Now your buttons can be anywhere on the page.现在您的按钮可以位于页面上的任何位置。 Make sure you have both form and button ID's assigned确保您已分配表单和按钮 ID

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

相关问题 如何在彼此相邻的两个单选按钮之间增加间距 - How to add spacing between two radio buttons that are next to each other 如何将2张图像并排放置,这些图像充当具有2个不同费用金额的Stripe付款按钮? - How can I put 2 images next to each other and the images act as my Stripe payment buttons with 2 different charge amounts? 从不同的表中提取列并彼此相邻显示 - extract columns from different tables and display next to each other 如何在侧面html标签中使图片彼此相邻 - How to make pictures next each other in the center in side html tag 如何从数组彼此相邻设置多个字符串 - how to set multiple strings from array next to each other 如何显示数据库中彼此相邻的列表项? - How to display list items from database next to each other? 如何从mysqli查询中将文本并排放置 - How to put text next to each other from mysqli query PHP 单选按钮在第二个循环中彼此相邻 - PHP radio buttons next to each other in second for loop 如何使2个网站相互托管在不同的云服务器上 - How to make 2 website communicate with each other hosted on different cloud server 从数组中选择随机值时,请确保两个特定的值不会彼此相邻出现 - when selecting random values from arrays, make sure two certain ones do not appear next to each other
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM