亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

輸入式密碼不可移動

輸入式密碼不可移動

海綿寶寶撒 2021-12-23 16:01:06
我有這個代碼,無論我做什么,第一個輸入都不會移動,唯一讓它移動的是 float:right; 但我不希望它像這樣我什至創建了這個 div->P 所以它可能會移動。有沒有人遇到過這個問題?它可能會干擾我的js嗎?這是我唯一能想到的 rn                .inner {                    display:inline-block;                    margin-right:500px;                }                .pswd {                    display:inline-block;                    margin-right:500px;                           }          </style>        </head>        <body>            <div class="P">                <input class="inner" type="password" id="pswd">                <input class="inner" type="button" value="Submit" onclick="checkPswd();"/>            </div>        <script type="text/javascript">            function checkPswd() {                var confirmPassword = "admin";                var password = document.getElementById("pswd").value;                if (password == confirmPassword) {                     window.location="A.html";                }                else{                    alert("Password incorrect.");                }            }        </script>
查看完整描述

2 回答

?
守候你守候我

TA貢獻1802條經驗 獲得超10個贊

如果您使用 ID 選擇器而不是類選擇器(即使用#而不是.),這應該可以工作:


            #pswd {

                display:inline-block;

                margin-right:500px;           

            }


查看完整回答
反對 回復 2021-12-23
?
隔江千里

TA貢獻1906條經驗 獲得超10個贊

有多種方法可以在屏幕上垂直和水平居中對齊 div。


我也用過display:flex。


  'use-strict'


  function checkPswd(form) {

    const confirmPassword = "admin";

    let passwordProvided = form.elements.newPassword.value;


    if (passwordProvided === confirmPassword) {

      // If correct

    } else {

      // If failure

    }


    // to prevent default action

    return false;

  }

.form--wrapper {

  width: 150px;

  height: 150px;

  position: absolute;

  top: 0;

  bottom: 0;

  left: 0;

  right: 0;

  margin: auto;

}


form {

  display: flex;

  flex-direction: column;

  justify-content: center;

  height: 100%;

  width: 100%;

  border: 2px dashed orange

}

<div class="form--wrapper">

  <form name="change-password" onsubmit="return checkPswd(this)">

    <input class="inner" name="newPassword" type="password">

    <input class="inner" type="submit" value="Submit" />

  </form>

</div>


查看完整回答
反對 回復 2021-12-23
  • 2 回答
  • 0 關注
  • 128 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號