2017-10-14 140 views
1

所以我對整個HTML/CSS的東西很陌生,我學到的大部分東西都是來自這裏或者是我用Google的問題,我差不多完成了我的任務,但是我似乎無法弄清楚如何在同一行上打印兩個標籤單詞。 https://i.stack.imgur.com/TRdxs.png登錄屏幕在一行上確認密碼

[<!DOCTYPE html> 
<html> 
<head> 
<meta charset="UTF-8"> 
<title></title> 
<style> 
body {background-color: black;} 
div {} 
label {display:inline-block;width:235px;margin-left: 20px; margin-top: 20px; font-size: 25px; font-family: Calibre; color: white; text-align: left;} 
input {margin-top: 20px; margin-right: 20px;padding: 12px 20px;} 
#main {border: 5px solid white; width: 600px; height: 400px;} 
button {margin-left: 320px; margin-top: 20px; margin-bottom: 20px; background-color:#00BB00; width:120px; height: 40px; 
color: white; 
font-size: 20px; 
border-radius: 46px; 
-moz-border-radius: 46px; 
-webkit-border-radius: 46px; 
border: 0px solid #800000; 
font-family: Calibre} 
</style> 
</head> 
<body> 
<div id="main"> 
<form action="/web.engineering" method="post"> 
    <div> 
    <label>Username:</label> 
    <input type="text"placeholder="Username" name="username" required> 
    </div> 
    <div> 
    <label>First name:</label> 
    <input type="text" placeholder="First name" name="firstname" required> 
    </div> 
    <div> 
    <label>Last name:</label> 
    <input type="text" placeholder="Last name" name="lastname" required> 
    </div> 
    <div> 
    <label>Password:</label> 
    <input type="password" placeholder="Enter password" name="password" required> 
    </div> 
    <div> 
    <label>Passwordconfirmation:</label> 
    <input type="password" placeholder="Re-enter password" name="Repeat password" required> 
    </div> 
    <div> 
    <button type="submit" ><b>Register</b></button> 
    </div> 
</form> 

</div> 

</body> 
</html>][1] 

所以這是我和畫面是什麼,我要get.Can請你告訴我如何在文本框中之前在同一行打印密碼確認。 在此先感謝

+0

您能否提供預期輸出的圖像?或者更加解釋什麼是問題? –

+0

嘗試使用#main div顯示:內嵌塊屬性。 –

回答

0

根據空間容器div有,第二個使用display: flex;flex-basis: 230px;

body { 
 
    background-color: black; 
 
} 
 

 
div {} 
 

 
#main form>div { 
 
    display: flex; 
 
} 
 

 
label { 
 
    flex-basis: 230px; 
 
    margin-left: 20px; 
 
    margin-top: 20px; 
 
    font-size: 23px; 
 
    font-family: Calibre; 
 
    color: white; 
 
    text-align: left; 
 
} 
 

 
input { 
 
    margin-top: 20px; 
 
    margin-right: 20px; 
 
    padding: 12px 20px; 
 
} 
 

 
#main { 
 
    border: 5px solid white; 
 
    width: 600px; 
 
    height: 400px; 
 
} 
 

 
button { 
 
    margin-left: 320px; 
 
    margin-top: 20px; 
 
    margin-bottom: 20px; 
 
    background-color: #00BB00; 
 
    width: 120px; 
 
    height: 40px; 
 
    color: white; 
 
    font-size: 20px; 
 
    border-radius: 46px; 
 
    -moz-border-radius: 46px; 
 
    -webkit-border-radius: 46px; 
 
    border: 0px solid #800000; 
 
    font-family: Calibre 
 
}
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <meta charset="UTF-8"> 
 
    <title></title> 
 
    <style> 
 

 
    </style> 
 
</head> 
 

 
<body> 
 
    <div id="main"> 
 
    <form action="/web.engineering" method="post"> 
 
     <div> 
 
     <label>Username:</label> 
 
     <input type="text" placeholder="Username" name="username" required> 
 
     </div> 
 
     <div> 
 
     <label>First name:</label> 
 
     <input type="text" placeholder="First name" name="firstname" required> 
 
     </div> 
 
     <div> 
 
     <label>Last name:</label> 
 
     <input type="text" placeholder="Last name" name="lastname" required> 
 
     </div> 
 
     <div> 
 
     <label>Password:</label> 
 
     <input type="password" placeholder="Enter password" name="password" required> 
 
     </div> 
 
     <div> 
 
     <label>Password confirmation:</label> 
 
     <input type="password" placeholder="Re-enter password" name="Repeat password" required> 
 
     </div> 
 
     <div> 
 
     <button type="submit"><b>Register</b></button> 
 
     </div> 
 
    </form> 
 

 
    </div> 
 

 
</body> 
 

 
</html>]

希望這將工作首先給字體大小!

+0

謝謝你的工作就像一個魅力^^ –

+0

@СимеонПецанов - 你的歡迎,請你給我投票:) –

+0

我與低於15的聲望,投票記錄,但不可見。一刻我打你應該得到的聲譽你的投票:(對不起,關於那 –

0

使標籤的寬度大於或小於標籤的字體大小。既然你有固定的寬度,那麼這兩個單詞都不適合該字體大小的235px的寬度。我試着寬度爲240px,它位於同一行,並且字體大小爲24px,它位於同一行。