Text label with several rows - html

2 things are bothering me atm...
First:
I'm trying to create a contact section with few simple text input labels, one of which has several rows displayed. That would be the "message" ofc.
The problem is that i cant find where and how can i add those rows and limit how many cols can be typed in every row.
Second:
How can i make them clickable/editable? When i add them to website they have placeholders but i cant click and enter text inside them (lets say to fill out a form)...
The code snippet is below, and THANK YOU for helping me to learn that stuff...
.kontakt {
display: block;
padding-top: 10px;
padding-bottom: 15px;
padding-left: 15px;
padding-right: 15px;
border: 3px solid #20202f;
border-radius: 10px;
position: absolute;
top: 50px;
left: 50px;
font-size: 24px;
background-color: rgba(51, 52, 89, 0.85);
}
#yourname {
font-size: 20px;
margin-bottom: 10px;
}
#mail {
font-size: 20px;
margin-bottom: 10px;
}
#message {
font-size: 20px;
margin-bottom: 25px;
}
.messagebutton {
width: 75px;
height: 35px;
font-size: 15px;
border-radius: 5px;
background-color: #bfbfff;
color: black;
margin-left: 172px;
margin-bottom: 5px;
}
<div class="kontakt">
<div class="nametext">
<label for="ime">your name</label>
</div>
<div class="namebox">
<input type="text" id="yourname" placeholder="your name">
</div>
<div class="mailtext">
<label for="mail">e-mail</label>
</div>
<div class="mailbox">
<input type="email" id="mail" placeholder="your email">
</div>
<div class="messagetext">
<label for="Message">message</label>
</div>
<div class="messagebox">
<input type="text" id="message" placeholder="Your message goes here">
</div>
<button type="button" class="messagebutton">SEND</button>
</div>

Awesome stuff!
To get a multi-line message, use the textarea tag, rather than the input. So,
<div class="messagebox">
<textarea id="message" rows="3" placeholder="Your message goes here"></textarea>
</div>
The ROWS attribute will get your number of lines, or you can use the browser default.
https://www.w3schools.com/tags/tag_textarea.asp
As for being editable, they are by default - and your example seems to be working correctly.

Related

How can I remove the black outline around my input areas?

So I have these black boxes go round the input area on the form I am building. Is there a way I can remove this, I am also using bootstrap not sure if that is affecting it but if there is any ideas. Greatly appreciated!
.form-input-styling {
border-radius: 0 2em;
padding: 0 10px;
width: 50%;
border: none;
line-height: 2em;
margin-bottom: 20px;
background-color: #f25b43;
}
<div class="row">
<div class="col-12"><input class="form-input form-input-styling" type="text" id="fname" name="fname" required placeholder="Name"></div>
<div class="col-12"><input class="form-input form-input-styling" type="email" id="email" name="email" required placeholder="Email"></div>
<div class="col-12"><input class="form-input form-input-styling" type="tel" id="phone_num" name="phone_num" placeholder="Phone Number"></div>
<div class="col-12"><textarea id="text-area" name="textarea" rows="4" cols="50" placeholder="Enter Your Message Here"></textarea></div>
<div class="col-12"><input type="submit" value="Submit"></div>
</div>
Add outline: none; to your css for the input element.
.form-input-styling {
border-radius: 0 2em;
padding: 0 10px;
width: 50%;
border: none;
outline: none;
line-height: 2em;
margin-bottom: 20px;
background-color: #f25b43;
}

Why does the writable part of the form start from the middle?

Basically I tried to make a form for the first time, but I can't manage to understand why the writable area doesn't start from the beginning. I think it might have something to do with the padding, but I'm not sure. I know that the answer will probably be obvious, but I'm pretty new to this enviroment and to be honest I can't figure it out. Obviously there isn't all of the code of the website, I just posted the interested part.Thank you in advance.
label{
font-size: 30px;
font-family: 'Raleway', sans-serif;
margin-left: -390px;
margin-right: 100px;
display: block;
margin-top: 70px;
}
input[type=text],
input[type=email],
textarea{
padding: 12px 200px;
box-sizing: border-box;
background-color: #222326;
border: none;
border-bottom: 1px solid #D9D9D9;
text-align: left;
}
.msg-label{
margin-left: -345px;
}
.email-label{
margin-left: -398px;
}
textarea{
margin-bottom: 100px;
padding-right: 300px 220px;
overflow:hidden;
margin-right: -50px;
}
<div id="contact-me">
<div id="center">
<h2>CONTACT ME</h2>
</div>
<div id="center">
<form action="action-page.php">
<label for="name" class="name-label">Name</label>
<input type="text" id="name" name="full-name" >
<label for="email" class="email-label">Email</label>
<input type="email" id="email" name="email">
<label for="message" class="msg-label">Message</label>
<textarea id="msg" name="message"></textarea>
<input type="submit" value="Submit">
</form>
</div>
</div>
input[type=text],
input[type=email],
textarea{
padding: 12px 200px;
box-sizing: border-box;
background-color: #222326;
border: none;
border-bottom: 1px solid #D9D9D9;
text-align: left;
}
its the padding that you have added in the snippet above. padding adds space within the element as such you are pushing everything inside.

How could I align my label text to the top left side of the input box?

Currently my web page looks like this
And I am wanting it to look like this
I have thought about putting "Email Address" and "ZIP" inside of their own span tag, but I am not sure the best way to approach it.
My code looks like this:
.emailBox {
padding-left: 13px;
font-family: Rubik;
z-index: 1;
top: 300px;
width: 317px;
height: 50px;
border-radius: 2px;
background-color: #f5f6f7;
border: none;
}
.zipBox {
margin-left: 10px;
padding-left: 13px;
font-family: Rubik;
z-index: 1;
top: 300px;
width: 90px;
height: 50px;
border-radius: 2px;
background-color: #f5f6f7;
border: none;
}
<div>
<form action="https://hooks.zapier.com/hooks/catch/1681335/pq0txq/" method="POST">
<label>Email Address <br>
<input type="email" name="email" placeholder="email#shinesolar.com" class="emailBox">
</label>
<label>ZIP <br>
<input id="zip" name="zip" type="text" pattern="[0-9]*" placeholder="72712" class="zipBox">
</label>
</form>
</div>

I can't alter the width of an item through CSS

I'm a beginner in front-end development and I'm working on a survey website. My website has a lot of input fields and I want to alter their width per their nature but I'm not able to do it for some reason. The item is not in a flex container and yet changing the value in the width attribute makes no difference.
I'm trying to change the width of my input field in my customerAge div to make it small enough to just hold 2 digits.
This is my codepen link: https://codepen.io/omaroz92/full/VBWbae/
I'd appreciate a detailed explanation on why changing the value in the width attribute made no difference.
body {
background-color: #98AFC7;
}
#title {
text-align: center;
font-family: Arial, Times, serif;
font-style: oblique;
color: white;
}
#screen-belly {
background-color: rgb(250, 250, 250);
margin: 0 auto;
border-radius: 4px;
width: 75%;
max-width: 1000px;
padding: 10px;
padding-top: 20px;
}
p {
text-align: center;
font-family: monospace, serif;
font-size: 15px;
}
.container {
width: 75%;
max-width: 600px;
margin: 0 auto;
}
.row {
display: flex;
}
.customerAge {
width: 100px;
}
input {
flex: 1;
height: 20px;
min-width: 0;
padding: 5px;
margin: 10px;
border: 1px solid #c0c0c0;
border-radius: 2px;
}
<h1 id="title">Survey Form</h1>
<div id="screen-belly">
<p>Please take the short Survey to hep us improve our services</p>
<div class="container">
<div class="row">
<input autofocus type="text" name="name" id="name" placeholder="First name" required>
<input type="text" name="name" id="name" placeholder="Last Name" required>
</div>
<div class="row">
<input type="text" name="email" id="email" placeholder="e-Mail address" required>
</div>
<div class="customerAge">
<input type="number" name="age" id="Age" placeholder="age" required>
</div>
</div>
</div>
You've wrapped the Age input in customerAge div. But you've applied the width property to the parent, not to the input.
You can try this in your css code:
.customerAge input#Age {
width: 31px;
}
And you can change 31px to the value you want.
If you are confused, the input#Age after .customerAge, means: the input field with Age id that is inside of the customerAge class.

Issue getting a submit button to center in a wrap

For some reason I cannot get the submit button to center. I have tried everything from text-align: center; to margin: 0 auto; to a left and right margin at auto. The button will not center anyway I try. What am I failing to do?
.contactForm {
border: 2px solid black;
background-color: #F0F0F0;
width: 40%;
margin: 0 auto;
padding: 40px;
}
.contactButton {
margin-top: 15px;
margin-right: auto;
margin-bottom: 15px;
margin-left: auto;
width: 425px;
font-size: 20px;
font-weight: bold;
padding: 14px;
cursor: pointer;
background-color: #800000;
border: none;
color: #FFFFFF;
text-align: center;
}
<div class="contactForm">
<form action="" method="post" id="mycontactform">
<input type="text" class="inputbar" name="name" placeholder="Full Name" required>
<input type="email" class="inputbaremail" name="email" placeholder="Email" required>
<textarea rows="4" cols="50" name="message" class="inputbarmessage" placeholder="Message" required></textarea>
<label for="contactButton">
<input type="button" class="contactButton" value="Send Message" id="submit">
</label>
</form>
</div>
It's hard to center is, because it is inside a label. The label is an inline element too and will size around the button. Therefor text-align: center and other solutions don't work.
In the snippet below, I've made the label show itself as a block element, which automatically occupies the available width of the parent. Then you can easily center the button inside it:
The added piece:
label[for="contactButton"] {
display: block;
text-align: center;
}
The whole code:
.contactForm {
border: 2px solid black;
background-color: #F0F0F0;
width: 40%;
margin: 0 auto;
padding: 40px;
}
.contactButton {
margin-top: 15px;
margin-right: auto;
margin-bottom: 15px;
margin-left: auto;
width: 425px;
/* Make sure the button isn't too wide on small screens */
max-width: 80%;
font-size: 20px;
font-weight: bold;
padding: 14px;
cursor: pointer;
background-color: #800000;
border: none;
color: #FFFFFF;
text-align: center;
}
label[for="contactButton"] {
display: block;
text-align: center;
}
<div class="contactForm">
<form action="" method="post" id="mycontactform">
<input type="text" class="inputbar" name="name" placeholder="Full Name" required>
<input type="email" class="inputbaremail" name="email" placeholder="Email" required>
<textarea rows="4" cols="50" name="message" class="inputbarmessage" placeholder="Message" required></textarea>
<label for="contactButton">
<input type="button" class="contactButton" value="Send Message" id="submit">
</label>
</form>
</div>
Use text-align:center on the parent div.
Fiddle: http://jsfiddle.net/gopal/su3vg018/
.contactForm {
text-align:center;
}
Add this to your css file:
.contactForm label[for="contactButton"] {
display: block;
text-align: center;
}