0

谁能帮我?我需要在 html 表单中的文本框之后放置一个 div。即标签、文本框和新的 div 在同一行

请查看我的 html 代码。我还没有添加 div 代码。

请任何人都可以帮助我在同一行中添加一个 div 而无需对此代码进行任何修改。因为我制作了几个 CSS 代码来对齐这个标签和文本框

<form action="operates/signup.php" method="post" name="signupform" id="signupform">

      <label id="fnamelabel" for="fnam">First Name :</label>
      <input type="text" name="fnam" id="fnam" tabindex="1" />

    <p>
      <label id="lnamelabel"  for="lnam">Last Name :</label>
      <input type="text" name="lnam" id="lnam" tabindex="2" />
    </p>
    <p>
      <label id="yemail" for="email">Your Email :</label>
      <input type="text" name="email" id="email" tabindex="3" />
    </p>
    <p>
      <label id="reemail" for="remail">Re-enter Email :</label>
      <input type="text" name="remail" id="remail" tabindex="4" />
    </p>
    <p>
      <label id="npass" for="password">New Password :</label>
      <input type="text" name="password" id="password" tabindex="5" />
    </p>
    <p>
      <label id="mskill" for="bskill">Main Skill :</label>
      <select name="bskill" id="bskill" tabindex="6">
      </select>
    </p>
    <p>
      <input type="checkbox" name="termsanc" id="termsanc" tabindex="6" />
      <label id="terms" for="termsanc">I agreed the <a href="index.html">Terms and Conditions</a></label>
    </p>
    <div id="signupbutton" onclick="document.forms.signupform.submit()"></div>
  </form>

谢谢

4

3 回答 3

0

您可以将 div 设置为内联样式,但您应该使用跨度。

于 2012-06-29T13:39:53.703 回答
0
<label id="fnamelabel" for="fnam" style = "display:inline">First Name :</label>
<input type="text" name="fnam" id="fnam" tabindex="1" style = "display:inline" />
<div id="newDiv" style = "display:inline"></div>

通常我不会使用这样的内联 CSS,但由于你没有发布 css,我觉得这是必要的。

于 2012-06-29T13:46:42.233 回答
0

首先,让我们处理那个标记!

<form action="operates/signup.php" method="post" name="signup_form">
    <label>First Name:
        <input name="first_name"></label>
    <label>Last Name:
        <input name="last_name"></label>
    <label>Your Email:
        <input type="email" name="email"></label>
    <label>Please Reenter Your Email:
        <input type="email" name="validate_email"></label>
    <label>New Password:
        <input type="password" name="password"></label>
    <label>Main Skill:
        <input name="main_skill"></label>
    <label><input type="checkbox" name="terms_and_conditions">I agreed the <a href="index.html">Terms and Conditions</a></label>

    <button type="submit">Submit</button>
</form>
<style type="text/css">
    form {
        display: block;
        width: 400px;
    }
    label {
        display: block;
        padding: 5px;
        margin: 5px;
    }
    form label input {
        float: right;
    }
    input[type=checkbox] {
        float: none;
    }
</style>

好了,现在看起来是不是好多了?


至于最初的问题,不要使用 a divdiv是一个完全无语义的块级元素。如果您想要一个内联元素(即显示在同一行),请使用 a span,它是一个完全无语义的内联级元素

于 2012-06-29T13:54:05.553 回答