【问题标题】:issue with inputs inside a form表单内的输入问题
【发布时间】:2015-09-10 04:28:51
【问题描述】:

1 个问题。- 我无法对齐子标题中的 2 个输入表单

2 问题。- 当您在“副标题”之外单击时,我需要再次显示“注册”和“登录”这两个词,除非您在输入中写入内容

$(document).ready(function() {
    $('.register').click(function() {
        $('.register').hide();
 });
});
$(document).ready(function() {
    $('.registers').hide();
});
$(document).ready(function() {
    $('.register').click(function() {
        $('.registers').show();
 });
});
.subheader {
	background: #F3F3F3;
	margin: 0 auto;
	width: 100%;
	height: 30px;

}
.register p {
	display: inline-block;
	float: right;
	color: #179B75;
	font-size: 12px;
	padding: 0;
	padding-right: 8px;
}
.register {
	display: block;
	left: 75%;
	position: fixed;
	top: 5px;
	z-index: 10005;
	height: 30px;
}
.register>p>input {
	width: 100px;
	height: 20px;
	border: 1px solid #c8c8c8;
	font-family: FuturaLight;
	text-indent: 20px;
	font-size: 12px;
	float: right;
	display: none;
	color: #179B75;
}
.register>p>input:enabled{
	cursor: text;
}
.forms {
	width: 400px;
	height: 30px;
	display:inline-block;
	float:right;
}
.registers {
	width: 400px;
	height: 30px;
	display: inline-block;
	float:right;
}
.registerformsleft {
	width: 130px;
	height: 25px;
	display: inline-block;
	position: inherit;
	float: left;
}
.registerformsright {
	width: 130px;
	height: 25px;
	display: inline-block;
	position: inherit;
	float: right;
}
.register {
	cursor:pointer;
}
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
    <title>Prueba</title>
    <link rel="stylesheet" href="css/Principal.css"/>
    <link rel="stylesheet" href="css/main.css" />
    <link rel="stylesheet" href="css/jquery.bxslider.css" />
  </head>
  <body>
    <header>
          <div class="subheader">
            <div class="register">  
              <p>Login
              </p>
               <p>|</p>
              <p>Register</p>
            </div>
            <div class="forms">
              <form class="registers" action="demo_form.asp">
                <input class="registerformsleft" type="email" name="email" value="Email" placeholder="Format: algo@gmail.com" onfocus="if (this.value=='Email') this.value='';"><br>
                <input class="registerformsright" type="password" name="Password" size="10" value="Password" onfocus="if (this.value=='Password') this.value='';"><br>
                <input class="submit" type="submit" value="Submit">
              </form>
            </div> 
          </div>
    </header>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

    <script src="js/jquery.inputs.js"></script>
   </body>
</html>

【问题讨论】:

    标签: javascript jquery html css input


    【解决方案1】:

    1 个问题:

    删除两个输入字段之间和提交按钮之前的 br 标签,并像这样更改您的样式:

    .registerformsright {
        width: 130px;
        height: 25px;
        display: inline-block;
        position: inherit;
        margin-left: 5px;
    }
    

    【讨论】:

    • br 标签?我那里没有 br 标签
    • 在输入标签的末尾
    • 这个?
    • 我不是说那一行,那行很好,但是在输入标签(class="registerformsleft" 和 class="registerformsright")的入口处有两个 br 标签


    • 这一行末尾的
      从右边开始
    【解决方案2】:

    请试试这个:

    CSS:

    .subheader {
      background: #F3F3F3;
      margin: 0 auto;
      width: 100%;
      height: 30px;
    }
    .register p {
      display: inline-block;
      float: right;
      color: #179B75;
      font-size: 12px;
      padding: 0;
      padding-right: 8px;
    }
    .register {
      display: block;
      left: 75%;
      position: fixed;
      top: 5px;
      z-index: 10005;
      height: 30px;
    }
    .register>p>input {
      width: 100px;
      height: 20px;
      border: 1px solid #c8c8c8;
      font-family: FuturaLight;
      text-indent: 20px;
      font-size: 12px;
      float: right;
      display: none;
      color: #179B75;
    }
    .register>p>input:enabled {
      cursor: text;
    }
    .forms {
      width: 400px;
      height: 30px;
      display: inline-block;
      float: right;
    }
    .registers {
      width: 400px;
      height: 30px;
      display: inline-block;
      float: right;
    }
    .registerformsleft {
      width: 130px;
      height: 25px;
      display: inline-block;
      position: inherit;
      float: left;
    }
    .registerformsright {
        width: 130px;
        height: 25px;
        display: inline-block;
        position: inherit;
        margin-left: 5px;
    }
    .register {
      cursor: pointer;
    }
    

    DEMO

    【讨论】:

      【解决方案3】:

      1 个问题:

      只需删除两个输入元素之间的&lt;br&gt; 标签



      2 问题:

      $(document).ready(function() {
        $('.register').click(function() {
          $('.register').hide()
        });
        $('.registers').hide();
        $('.register').click(function() {
          $('.registers').show();
        });
      
        $(document).mouseup(function(e) {
          var container = $(".registers");
          var email = $('input[name = "email"]');
          var password = $('input[name = "Password"]');
          if (!container.is(e.target) && container.has(e.target).length === 0) {
            if ((email.val() === email[0].defaultValue || !email.val()) && (password.val() === password[0].defaultValue || !password.val())) {
              container.hide();
              $('.register').show();
            }
          }
        });
      });
      .subheader {
        background: #F3F3F3;
        margin: 0 auto;
        width: 100%;
        height: 30px;
      }
      .register p {
        display: inline-block;
        float: right;
        color: #179B75;
        font-size: 12px;
        padding: 0;
        padding-right: 8px;
      }
      .register {
        display: block;
        left: 75%;
        position: fixed;
        top: 5px;
        z-index: 10005;
        height: 30px;
      }
      .register>p>input {
        width: 100px;
        height: 20px;
        border: 1px solid #c8c8c8;
        font-family: FuturaLight;
        text-indent: 20px;
        font-size: 12px;
        float: right;
        display: none;
        color: #179B75;
      }
      .register>p>input:enabled {
        cursor: text;
      }
      .forms {
        width: 400px;
        height: 30px;
        display: inline-block;
        float: right;
      }
      .registers {
        width: 400px;
        height: 30px;
        display: inline-block;
        float: right;
      }
      .registerformsleft {
        width: 130px;
        height: 25px;
        display: inline-block;
        position: inherit;
        float: left;
      }
      .registerformsright {
        width: 130px;
        height: 25px;
        display: inline-block;
        position: inherit;
        float: right;
      }
      .register {
        cursor: pointer;
      }
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <header>
        <div class="subheader">
          <div class="register">
            <p>Login
            </p>
            <p>|</p>
            <p>Register</p>
          </div>
          <div class="forms">
            <form class="registers" action="demo_form.asp">
              <input class="registerformsleft" type="email" name="email" value="Email" placeholder="Format: algo@gmail.com" onfocus="if (this.value=='Email') this.value='';">
      
              <input class="registerformsright" type="password" name="Password" size="10" value="Password" onfocus="if (this.value=='Password') this.value='';">
              <input class="submit" type="submit" value="Submit">
            </form>
          </div>
        </div>
      </header>

      使用THIS ANSWER作为参考

      【讨论】:

        猜你喜欢
        • 2020-12-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-06-08
        • 1970-01-01
        • 1970-01-01
        • 2016-02-12
        相关资源
        最近更新 更多