2017-02-28 7 views
0

登録フォームを中心に配置しました。また、ラベルを作成して表示ブロックを使用しました。しかし、私の入力ボックスは上部の上に線を表示していません。なぜ私の行クラスの高さを設定していないのに、正しく動作しないのですか?私はそれが自動的に私の行クラスの内容に応じて大きくなるようにします。私の画像を参照してください。入力ボックスのスタイルが正しく機能していません

Create account form

* { 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 

 
body { 
 
    width: auto; 
 
    font-family: "Gidole", sans-serif; 
 
} 
 

 
h1{ 
 
    padding: 15px; 
 
    text-align: center; 
 
} 
 

 

 
@font-face { 
 
    font-family: "Gidole"; 
 
    src: url(CODE Light.otf); 
 
} 
 

 

 
.container { 
 
    width: 960px; 
 
    height: 600px; 
 
    margin-left: auto; 
 
    margin-right: auto; 
 
    position: relative; 
 
    background: red; 
 
    top: 50px 
 
} 
 

 
.row { 
 
    width: 320px; 
 
    position: absolute; 
 
    top: 50%; 
 
    left:50%; 
 
    transform: translate(-50%,-50%); 
 
    color: #191919; 
 
    background-color: #F2FFFA; \t 
 
    font-family: "Gidole", sans-serif; 
 
    padding: 10px 55px 40px; \t 
 

 
} 
 

 
label { 
 
    max-width:300px; 
 
    display: block; 
 
    text-align:left; 
 
} 
 

 
input { 
 
    width: 100%; 
 
} 
 

 
#submit { 
 
    display: block; 
 
    width: 100%; 
 
    padding: 5px 10px 5px 10px; 
 
    color: #ffffff; 
 
    background-color: #B73737;; 
 
} 
 

 
select { 
 
    width: 100%; 
 
}
<div class="container"> 
 
    <div class="row"> 
 

 
    <div class="myForm"> 
 
     <form action="register.php" method="POST"> 
 
     <h1> Create an account</h1> <br/> 
 
     <?php echo registration_error($errors1); ?> 
 
     <label for="">Username</label><input type="text" name="username" size="30" /> <br/><br/> 
 
     <label for="">Password</label><input type="password" name="password" size="30"/> <br/><br/> 
 
     <label for="">First Name</label><input type="text" name="firstName" size="30" /> <br/><br/> 
 
     <label for="">Last Name</label><input type="text" name="lastName" size="30"> <br/><br/> 
 
     <label for="">Email address</label><input type="text" name="email" size="30"> <br/><br/> 
 
     <label for="">Gender</label><select name="gender" id="gender" > 
 
      <option value="male"> Male </option> 
 
      <option value="female"> Female </option> 
 
      <option value="others"> Others </option> 
 
      <option value="others"> Prefer not to say </option> 
 
     </select> <br/><br/> 
 
      <label for="">Age</label><input type="number" name="age"> <br/><br/> 
 
     <div class="center"> 
 
      <input type="submit" name="submit" value="Register" id="submit"> 
 
     </div> 
 
     </form> 
 
    </div> 
 
    </div> 
 
</div>

+0

だから、 'border'を設定する必要がありますか? – Huelfe

+0

なぜ入力ボックスに上の罫線が表示されていないのかを知る必要があります。 – studentAir01

+0

問題を示すjsfiddleを作成します。ブラウザのズームなどがあるかもしれません。 – Huelfe

答えて

0

CSS Resetを使用することをお勧めします。なぜなら、あなたのコードはIEで完璧に動作するからです。

コードのbox-sizingは、に設定されています。ブラウザのデフォルト、つまりbox-sizing:content-box;です。したがってtop-borderが原因borders

のベストプラクティスbox-sizing: border-box;修正してコードを追加しCSS ResetNormalizer.css

を使用されるだろうが撮影したサイズに隠されてきています。

* { 
 
    margin: 0; 
 
    padding: 0; 
 
    box-sizing: border-box; 
 
    /* try commenting this property */ 
 
} 
 

 
body { 
 
    width: 100%; 
 
    font-family: "Gidole", sans-serif; 
 
} 
 

 
h1 { 
 
    padding: 15px; 
 
    text-align: center; 
 
} 
 

 
.container { 
 
    width: 960px; 
 
    height: 600px; 
 
    margin-left: auto; 
 
    margin-right: auto; 
 
    position: relative; 
 
    background: red; 
 
    top: 50px 
 
} 
 

 
.row { 
 
    width: 320px; 
 
    position: absolute; 
 
    top: 50%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    color: #191919; 
 
    background-color: #F2FFFA; 
 
    font-family: "Gidole", sans-serif; 
 
    padding: 10px 55px 40px; 
 
} 
 

 
label { 
 
    max-width: 300px; 
 
    display: block; 
 
    text-align: left; 
 
} 
 

 
input { 
 
    width: 100%; 
 
} 
 

 
#submit { 
 
    display: block; 
 
    width: 100%; 
 
    padding: 5px 10px 5px 10px; 
 
    color: #ffffff; 
 
    background-color: #B73737; 
 
    ; 
 
} 
 

 
select { 
 
    width: 100%; 
 
}
<div class="container"> 
 
    <div class="row"> 
 
    <div class="myForm"> 
 
     <form action="register.php" method="POST"> 
 
     <h1> Create an account</h1> <br/> 
 
     <?php echo registration_error($errors1); ?> 
 
     <label for="">Username</label><input type="text" name="username" size="30" /> <br/><br/> 
 
     <label for="">Password</label><input type="password" name="password" size="30" /> <br/><br/> 
 
     <label for="">First Name</label><input type="text" name="firstName" size="30" /> <br/><br/> 
 
     <label for="">Last Name</label><input type="text" name="lastName" size="30"> <br/><br/> 
 
     <label for="">Email address</label><input type="text" name="email" size="30"> <br/><br/> 
 
     <label for="">Gender</label><select name="gender" id="gender"> 
 
        <option value="male"> Male </option> 
 
        <option value="female"> Female </option> 
 
        <option value="others"> Others </option> 
 
        <option value="others"> Prefer not to say </option> 
 
       </select> <br/><br/> 
 
     <label for="">Age</label><input type="number" name="age"> <br/><br/> 
 
     <div class="center"> 
 
      <input type="submit" name="submit" value="Register" id="submit"> 
 
     </div> 
 
     </form> 
 
    </div> 
 
    </div> 
 
</div>

+0

チップをありがとう!私はあなたのすべての助けに感謝します。それは今働いている。 – studentAir01

+0

素晴らしい!あなたは私の答えを正しいとマークし、それを閉じることができます。 –

0

label要素を使用して、間にスペースを追加する必要があるテキストボックスの上に重なっので、あなたの入力要素

に上マージンを追加しています
input { 
     width: 100%; 
     margin-top:3px; 
} 

* { 
 
     margin: 0; 
 
     padding: 0; 
 
    } 
 

 
    body { 
 
     width: auto; 
 
     font-family: "Gidole", sans-serif; 
 
    } 
 

 
    h1{ 
 
     padding: 15px; 
 
     text-align: center; 
 
    } 
 

 

 
    @font-face { 
 
     font-family: "Gidole"; 
 
     src: url(CODE Light.otf); 
 
    } 
 

 

 
    .container { 
 
     width: 960px; 
 
     height: 600px; 
 
     margin-left: auto; 
 
     margin-right: auto; 
 
     position: relative; 
 
     background: red; 
 
     top: 50px 
 
    } 
 

 
    .row { 
 
     width: 320px; 
 
     position: absolute; 
 
     top: 50%; 
 
     left:50%; 
 
     transform: translate(-50%,-50%); 
 
     color: #191919; 
 
     background-color: #F2FFFA; 
 
     font-family: "Gidole", sans-serif; 
 
     padding: 10px 55px 40px;  
 

 
    } 
 

 
    label { 
 
     max-width:300px; 
 
     display: block; 
 
     text-align:left; 
 
    } 
 

 
    input { 
 
     width: 100%; 
 
     margin-top:3px; 
 
    } 
 

 
    #submit { 
 
     display: block; 
 
     width: 100%; 
 
     padding: 5px 10px 5px 10px; 
 
     color: #ffffff; 
 
     background-color: #B73737;; 
 
    } 
 

 
    select { 
 
     width: 100%; 
 
    }
<div class="container"> 
 
    <div class="row"> 
 

 
     <div class="myForm"> 
 
      <form action="register.php" method="POST"> 
 
       <h1> Create an account</h1> <br/> 
 
       
 
       <label for="">Username</label><input type="text" name="username" size="30" /> <br/><br/> 
 
       <label for="">Password</label><input type="password" name="password" size="30"/> <br/><br/> 
 
       <label for="">First Name</label><input type="text" name="firstName" size="30" /> <br/><br/> 
 
       <label for="">Last Name</label><input type="text" name="lastName" size="30"> <br/><br/> 
 
       <label for="">Email address</label><input type="text" name="email" size="30"> <br/><br/> 
 
       <label for="">Gender</label><select name="gender" id="gender" > 
 
        <option value="male"> Male </option> 
 
        <option value="female"> Female </option> 
 
        <option value="others"> Others </option> 
 
        <option value="others"> Prefer not to say </option> 
 
       </select> <br/><br/> 
 
       <label for="">Age</label><input type="number" name="age"> <br/><br/> 
 
       <div class="center"> 
 
        <input type="submit" name="submit" value="Register" id="submit"> 
 
       </div> 
 
      </form> 
 
     </div> 
 
    </div> 
 
</div>

関連する問題