Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS How to add text to top of input box for contact forms

krys778

New Coder
Hello,

I'm having a problem where the text is on the bottom of each input box for my contact form. I'd like to make it so that the text is on the top of each input box. I have posted my code below as well as attached an image of my contact form.

HTML:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewpoint" content="width=device-width, initial-scale=1.0">
    <title>Easy Tutorials</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>

    <div class="hero">
<form>
    <div class="input-group"> 
    <input type="text" id="name" required>
    <label for="name">Twoje imię (wymagane)</label>
    </div>
    <div class="input-group"> 
    <input type="text" id="number" required>
    <label for="number">Adres E-mail (wymagane)</label>
    </div>
    <div class="input-group"> 
    <input type="email" id="email" required>
    <label for="email">Temat</label>
    </div>
    <div class="input-group"> 
    <textarea id="message" rows="8"></textarea>
    <label for="message">Twoja wiadomość</label>
    </div>
    <button type="submit">WYŚLIJ WIADOMOŚĆ</button>
</form>
    
    </div>


</body>
</html>


CSS:
*{
    margin: 0;
    padding: 0;
    font-family: 'poppins', sans-serif;
    box-sizing: border-box;
}
 .hero{
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
 form{
    width: 90%;
    max-width: 600px;
}
.input-group{
    margin-bottom: 30px;
    position: relative;
}
input, textarea{
    width: 100%;
    padding: 10px;
    outline: 0;
    border: 1px solid #000;
    color: #000;
    background: transparent;
    font-size: 15px;
}
label{
    display: block;
    position: absolute;
    height: 100%;
    top: 10;
    left: 10;
    margin: 10px 0;
}
button{
    padding: 10px 0;
    color: #000;
    outline: none;
    background: transparent;
    border: 1px solid #000;
    width: 100%;
    cursor: pointer;
}
Screenshot (658).png
 
Put the <label> before the <input>:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewpoint" content="width=device-width, initial-scale=1.0">
    <title>Easy Tutorials</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>

    <div class="hero">
<form>
    <div class="input-group">
    <label for="name">Twoje imię (wymagane)</label>
    <input type="text" id="name" required>
    </div>
    <div class="input-group">
    <label for="number">Adres E-mail (wymagane)</label>
    <input type="text" id="number" required>
    </div>
    <div class="input-group">
    <label for="email">Temat</label>
    <input type="email" id="email" required>
    </div>
    <div class="input-group">
    <label for="message">Twoja wiadomość</label>
    <textarea id="message" rows="8"></textarea>
    </div>
    <button type="submit">WYŚLIJ WIADOMOŚĆ</button>
</form>
    
    </div>


</body>
</html>
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom