I am having an issue where I am using text-align on my container to center all of the content within it, but would like to align my <span> elements to the left within that centered container. I have tried isolating the span elements in my css and using text-align: left; but have not had any success. I feel like it is a simple fix that is slipping my mind at the moment, but hope that it can be easily resolved.
HTML:
<div class="grid">
<div class="col-1-1" id="bar-registration-container">
<h1>Register</h1>
<div id="form-fields">
<form>
<label class="form-label" id="email">
<span>Email</span>
<br />
<input id="email" type="email" name="email" />
</label>
<br />
<label class="form-label" id="password">
<span>Password</span>
<br />
<input id="password" type="password" name="password" />
</label>
<br />
<label>
<input class="form-label" id="submit" type="submit" value="Register" />
</label>
</form>
</div>
</div>
</div>
CSS:
#bar-registration-container h1{
text-align: center;
}
#form-fields {
text-align: center;
background-color: #fff;
margin: 0 auto;
padding: 20px;
}
#form-fields input[type=email] {
font-size: 27px;
margin-bottom: 20px;
}
#form-fields input[type=password] {
font-size: 27px;
margin-bottom: 10px;
}
.form-label span {
color: #000;
margin-right: 10px;
}
#submit {
margin-top: 20px;
width: 300px;
height: 30px;
background-color: #000;
color: #fff;
font-size: 15px;
border: none;
}
I believe this snippet accomplishes what you want. I just gave the form-fields div a set width, and added a few styles to those span elements to get them to stretch the full width of that div, but be left-aligned.
#bar-registration-container h1{
text-align: center;
}
#form-fields {
width: 340px;
text-align: center;
background-color: #fff;
margin: 0 auto;
padding: 20px;
}
#form-fields input[type=email] {
font-size: 27px;
margin-bottom: 20px;
}
#form-fields input[type=password] {
font-size: 27px;
margin-bottom: 10px;
}
.form-label span {
display: inline-block;
text-align: left;
color: #000;
width: 100%;
margin-left: 5px;
}
#submit {
margin-top: 20px;
width: 300px;
height: 30px;
background-color: #000;
color: #fff;
font-size: 15px;
border: none;
}
<div class="grid">
<div class="col-1-1" id="bar-registration-container">
<h1>Register</h1>
<div id="form-fields">
<form>
<label class="form-label" id="email">
<span>Email</span>
<br />
<input id="email" type="email" name="email" />
</label>
<br />
<label class="form-label" id="password">
<span>Password</span>
<br />
<input id="password" type="password" name="password" />
</label>
<br />
<label>
<input class="form-label" id="submit" type="submit" value="Register" />
</label>
</form>
</div>
</div>
</div>
In order to left align your <span> you need to left align them and in edition to that you will have to use display:block. You actually were on right track you just missed display:block. Using display:block will make your <span> to act as a block element like <div> or <p> and then it will respect alignment properties better.
span{
text-align:left;
display:block;
margin-left:50px;// adjust yourself. Was just playing around with it.
}
Related
I am making a little form and have some line-breaks so that the text boxes are ontop of eachother. I can't seem to get the submit button and radio buttons to the right to start at the top of the form. Any ideas on what I need to do to achieve my goal design?I just need to shift the stuff to the right of the input text boxes up so they are inline with the "Restaurant Name" box
main {
margin-left: 88px;
margin-right: 88px;
}
#search_button {
height: 35px;
width: 60px;
border: 1px solid #ebebeb;
background-color: #bb0000;
font-size: 1em;
color: white;
border-radius: 8px;
margin-left: 12px;
cursor: pointer;
}
.textbox {
padding-left: 8px;
margin-bottom: 5px;
height: 28px;
width: 400px;
border: 1px solid #ebebeb;
border-radius: 3px;
}
<main>
<img id="header" src="images/header.jpeg">
<div>
<form>
<input type="text" placeholder="Restaurant Name" class="textbox"><br/>
<input type="text" placeholder="Location" class="textbox">
<button type="submit" id="search_button">
<i class="fa fa-search"></i>
</button>
<input type="radio" value="Best Match" name="search_terms">
<label>Best Match</label>
<input type="radio" value="Review Count" name="search_terms">
<label>Review Count</label> <br/>
<input type="radio" value="Rating" name="search_terms">
<label>Rating</label>
<input type="radio" value="Distance" name="search_terms">
<label>Distance</label> <br/>
</form>
</div>
</main>
My Current Code (BAD):
My Design Goal:
flexbox would be the best here. It has all the needed stuff to format your design to specifications. Also, don't be afraid to use divs, they exist to be used to format. HTML needs to be foolproof, since it will be used on a large number of devices, and it is prone to breaking if you do not nest well enough.
main {
margin-left: 88px;
margin-right: 88px;
}
#search_button {
height: 35px;
width: 60px;
border: 1px solid #ebebeb;
background-color: #bb0000;
font-size: 1em;
color: white;
border-radius: 8px;
margin-left: 12px;
cursor: pointer;
}
.textbox {
padding-left: 8px;
margin-bottom: 5px;
height: 28px;
width: 100%;
max-width: 400px;
box-sizing: border-box;
border: 1px solid #ebebeb;
border-radius: 3px;
}
.form {
display: flex;
flex-direction: row;
align-items: flex-start;
}
.left, .right {width: 50%;}
<main>
<img id="header" src="images/header.jpeg">
<div>
<form class="form">
<div class="left">
<input type="text" placeholder="Restaurant Name" class="textbox"><br/>
<input type="text" placeholder="Location" class="textbox">
</div>
<div class="right">
<button type="submit" id="search_button">
<i class="fa fa-search"></i>
</button>
<input type="radio" value="Best Match" name="search_terms">
<label>Best Match</label>
<input type="radio" value="Review Count" name="search_terms">
<label>Review Count</label> <br/>
<input type="radio" value="Rating" name="search_terms">
<label>Rating</label>
<input type="radio" value="Distance" name="search_terms">
<label>Distance</label> <br/>
</div>
</form>
</div>
</main>
I had to add a few more divs in order to make it cleanly.
When in doubt, use flexbox.
Biggest change is spliting your form into columns using flexbox and then using again flexbox in those columns to create desired layout.
Lines that I have added has been marked with /* added */. html you will figure out yourself.
main {
margin-left: 88px;
margin-right: 88px;
}
form { /* added */
display: flex; /* added */
column-gap: 12px; /* added */
} /* added */
.form-column { /* added */
width: fit-content; /* added */
display: flex; /* added */
flex-wrap: wrap; /* added */
} /* added */
.textbox {
padding-left: 8px;
margin-bottom: 5px;
height: 28px;
max-width: 400px;
width: 100%; /* added */
border: 1px solid #ebebeb;
border-radius: 3px;
}
.radio-group { /* added */
flex: 0 0 50%; /* added */
max-width: 50%; /* added */
} /* added */
#search_button {
height: 35px;
width: 60px;
border: 1px solid #ebebeb;
background-color: #bb0000;
font-size: 1em;
color: white;
border-radius: 8px;
cursor: pointer;
}
<main>
<form>
<div class="form-column">
<input type="text" placeholder="Restaurant Name" class="textbox">
<input type="text" placeholder="Location" class="textbox">
</div>
<div class="form-column">
<button type="submit" id="search_button">
<i class="fa fa-search"></i>
</button>
</div>
<div class="form-column">
<div class="radio-group">
<input type="radio" value="Best Match" name="search_terms">
<label>Best Match</label>
</div>
<div class="radio-group">
<input type="radio" value="Review Count" name="search_terms">
<label>Review Count</label>
</div>
<div class="radio-group">
<input type="radio" value="Rating" name="search_terms">
<label>Rating</label>
</div>
<div class="radio-group">
<input type="radio" value="Distance" name="search_terms">
<label>Distance</label>
</div>
</div>
</form>
</main>
This can be done well with flexbox. In addition to #GhostPengy, I have added a flexbox to the right area.
main {
margin-left: 88px;
margin-right: 88px;
}
#search_button {
height: 35px;
width: 60px;
border: 1px solid #ebebeb;
background-color: #bb0000;
font-size: 1em;
color: white;
border-radius: 8px;
margin-left: 12px;
cursor: pointer;
}
.textbox {
padding-left: 8px;
margin-bottom: 5px;
height: 28px;
width: 100%;
max-width: 400px;
box-sizing: border-box;
border: 1px solid #ebebeb;
border-radius: 3px;
}
.form {
display: flex;
flex-direction: row;
align-items: flex-start;
}
.left, .right {width: 50%;}
.right {
display: flex;
}
<main>
<img id="header" src="images/header.jpeg">
<div>
<form class="form">
<div class="left">
<input type="text" placeholder="Restaurant Name" class="textbox"><br/>
<input type="text" placeholder="Location" class="textbox">
</div>
<div class="right">
<div>
<button type="submit" id="search_button">
<i class="fa fa-search"></i>hello
</button>
</div>
<div>
<input type="radio" value="Best Match" name="search_terms">
<label>Best Match</label>
<input type="radio" value="Review Count" name="search_terms">
<label>Review Count</label> <br/>
<input type="radio" value="Rating" name="search_terms">
<label>Rating</label>
<input type="radio" value="Distance" name="search_terms">
<label>Distance</label> <br/>
</div>
</div>
</form>
</div>
</main>
Use display flex for making it desired and responsive for all kind of screens.
Code below - Working example here.
HTML -
<main>
<div>
<form>
<div class="form-container">
<div class="col-50">
<input
type="text"
placeholder="Restaurant Name"
class="textbox"
/><br />
<input type="text" placeholder="Location" class="textbox" />
</div>
<div class="col-50">
<div>
<button type="submit" id="search_button">
<i class="fa fa-search"></i>
</button>
</div>
<div class="radio-buttons-container">
<label class="radio-element">
<input type="radio" value="Best Match" name="search_terms" />
Best Match</label
>
<label class="radio-element">
<input type="radio" value="Review Count" name="search_terms" />
Review Count</label
>
<label class="radio-element">
<input type="radio" value="Rating" name="search_terms" />
Rating</label
>
<label class="radio-element">
<input type="radio" value="Distance" name="search_terms" />
Distance</label
>
<br />
</div>
</div>
</div>
</form>
</div>
</main>
And CSS -
* {
box-sizing: border-box;
}
main {
padding: 24px;
}
main .form-container {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.form-container .col-50 {
flex: 1;
min-width: 200px;
}
.form-container .col-50:last-of-type {
display: flex;
gap: 8px;
}
.radio-buttons-container {
display: flex;
flex-wrap: wrap;
}
.radio-buttons-container .radio-element {
min-width: 50%;
white-space: nowrap;
}
#search_button {
height: 35px;
width: 60px;
border: 1px solid #ebebeb;
background-color: #bb0000;
font-size: 1em;
color: white;
border-radius: 8px;
cursor: pointer;
}
.textbox {
padding-left: 8px;
margin-bottom: 5px;
height: 28px;
width: 100%;
max-width: 100%;
border: 1px solid #ebebeb;
border-radius: 3px;
}
You can divide form in two columns like this and can further customize CSS properties on those
You can open the following code snippet in full screen or can checkout the same on Codepen, you can make it responsive accordingly too
main {
margin-left: 88px;
margin-right: 88px;
}
#search_button {
height: 35px;
width: 60px;
border: 1px solid #ebebeb;
background-color: #bb0000;
font-size: 1em;
color: white;
border-radius: 8px;
margin-left: 12px;
cursor: pointer;
}
.textbox {
padding-left: 8px;
margin-bottom: 5px;
height: 28px;
width: 400px;
border: 1px solid #ebebeb;
border-radius: 3px;
}
* {
box-sizing: border-box;
}
.column {
float: left;
padding: 10px;
}
.row:after {
content: "";
display: table;
clear: both;
}
<main>
<img id="header" src="images/header.jpeg">
<div>
<form>
<div class="row">
<div class="column">
<input type="text" placeholder="Restaurant Name" class="textbox"><br />
<input type="text" placeholder="Location" class="textbox">
<button type="submit" id="search_button">
<i class="fa fa-search"></i>
</button>
</div>
<div class="column">
<input type="radio" value="Best Match" name="search_terms">
<label>Best Match</label>
<input type="radio" value="Review Count" name="search_terms">
<label>Review Count</label> <br />
<input type="radio" value="Rating" name="search_terms">
<label>Rating</label>
<input type="radio" value="Distance" name="search_terms">
<label>Distance</label> <br />
</div>
</div>
</form>
</div>
</main>
I want to create this form in css
HTML
<div class="contact__right">
<form action="" class="contact__form">
<div>
<label for="name" class="contact__form-label">Name</label>
<input type="text" id="name" class="contact__form-input">
</div>
<div>
<label for="email" class="contact__form-label">Email</label>
<input type="text" id="email" class="contact__form-input">
</div>
<div>
<label for="phone" class="contact__form-label">Phone</label>
<input type="text" id="phone" class="contact__form-input">
</div>
<div>
<label for="message" class="contact__form-label">Message</label>
<textarea name="message" id="message" cols="30" rows="10" class="contact__form-textarea"></textarea>
</div>
</form>
</div>
CSS
.contact {
&__form {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 105px 95px;
color: $white;
}
&__form-input,
&__form-textarea {
width: 300px;
height: 40px;
background: transparent;
border: 1px solid white;
border-radius: 2px;
margin-bottom: 25px;
}
&__form-textarea {
height: 150px;
}
&__form-label {
padding-right: 70px;
}
}
What I'm struggling with is alignment of inputs with labels and of textarea at the same line vertically.
textarea always sticks out at the side, because of its label which has longer text than the rest.
All the help will be appreciated.
I would not use a flexbox for the form, but for each <div> inside the form. The labels are vertically centered for each input field, except for the textarea. There the label is vertically aligned at the top. You can play with top padding there when desired.
* {
box-sizing: border-box;
}
.contact__right {
background-color: gray;
}
.contact__form {
padding: 105px 95px;
width: 100%;
color: white;
}
.contact__form>div {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 25px;
}
.contact__form-input,
.contact__form-textarea {
width: 300px;
height: 40px;
background: transparent;
border: 1px solid white;
border-radius: 2px;
}
.contact__form-textarea {
height: 150px;
}
label[for="message"].contact__form-label {
align-self: flex-start;
}
<div class="contact__right">
<form action="" class="contact__form">
<div>
<label for="name" class="contact__form-label">Name</label>
<input type="text" id="name" class="contact__form-input">
</div>
<div>
<label for="email" class="contact__form-label">Email</label>
<input type="text" id="email" class="contact__form-input">
</div>
<div>
<label for="phone" class="contact__form-label">Phone</label>
<input type="text" id="phone" class="contact__form-input">
</div>
<div>
<label for="message" class="contact__form-label">Message</label>
<textarea name="message" id="message" cols="30" rows="10" class="contact__form-textarea"></textarea>
</div>
</form>
</div>
Add following css code and your problem will be solved.
.contact__form-label {
vertical-align: top;}
Add this CSS rule for label:
label {
width: 100px;
display: inline-block;
vertical-align: top;
}
(otherwise label will be treated as an inline-element. This way you give it a fixed width and align it to the top)
If you don't like the alignment at the very top, you can add a padding-top ike in the following snippet:
form {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 105px 95px;
color: $white;
}
input,
textarea {
width: 300px;
height: 40px;
background: transparent;
border: 1px solid white;
border-radius: 2px;
margin-bottom: 25px;
}
textarea {
height: 150px;
}
label {
width: 100px;
display: inline-block;
vertical-align: top;
padding-top: 14px;
}
.contact__right {
background: #ccc;
}
<div class="contact__right">
<form action="" class="contact__form">
<div>
<label for="name" class="contact__form-label">Name</label>
<input type="text" id="name" class="contact__form-input">
</div>
<div>
<label for="email" class="contact__form-label">Email</label>
<input type="text" id="email" class="contact__form-input">
</div>
<div>
<label for="phone" class="contact__form-label">Phone</label>
<input type="text" id="phone" class="contact__form-input">
</div>
<div>
<label for="message" class="contact__form-label">Message</label>
<textarea name="message" id="message" cols="30" rows="10" class="contact__form-textarea"></textarea>
</div>
</form>
</div>
ยด
You are gonna have to do that manually I guess. Normally websites tend to break line after the labels and bring the input fields to the next line.
I am trying to float 4 boxes along the full width of my webpage with equal spacing between them.
Currently the output looks as follows:
This was achieved with the following HTML and CSS
.info {
background-color: black;
padding: 20px 20px 40px 20px;
margin-bottom: 10%;
}
.go_button {
width: 175px;
background-color: #01C3A7;
border: none;
cursor: pointer;
border-radius: 0.429rem;
color: #FFFFFF;
font-family: Circular, Helvetica, Arial, sans-serif;
font-size: 1.429rem;
font-weight: bold;
letter-spacing: 0px;
padding: 3px;
}
.box {
float: left;
}
<div class="info">
<div class="box_container">
<div class="box">
<input type="text" placeholder="Departure Station" id="depart">
<input type="hidden" id="departID" name="DeptStationID" style="display: none">
</div>
<div class="box">
<input type="text" placeholder="Arrival Station" id="arrive">
<input type="hidden" id="arriveID" name="ArrvStationID" style="display: none">
</div>
<div class="box">
<input type="text" id="datepicker" value="#DateTime.Now.Date.ToString(" yyyy/MM/dd ")" name="DeptDate">
</div>
<div class="box">
<input type="text" id="timepicker" name="time">
</div>
<div class="box"><button type="submit" name="Submit" class="go_button">Go</button></div>
</div>
</div>
The output I am trying to require is as follows:
I want this to be able to resize according to the screen display and therefore cannot set a margin using pixels. Currently when i do resize the output, it produces the following:
As you can see, the background color does not fill all four boxes. I have added height:auto and this does not fix the issue.
Please can you let me know how to fix these issues.
I would use flexbox with justify-content:space-between rather than floats
.info {
background-color: black;
padding: 20px 20px 40px 20px;
margin-bottom: 10%;
}
.go_button {
width: 175px;
background-color: #01C3A7;
border: none;
cursor: pointer;
border-radius: 0.429rem;
color: #FFFFFF;
font-family: Circular, Helvetica, Arial, sans-serif;
font-size: 1.429rem;
font-weight: bold;
letter-spacing: 0px;
padding: 3px;
}
.box_container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}
<div class="info">
<div class="box_container">
<div class="box">
<input type="text" placeholder="Departure Station" id="depart">
<input type="hidden" id="departID" name="DeptStationID" style="display: none">
</div>
<div class="box">
<input type="text" placeholder="Arrival Station" id="arrive">
<input type="hidden" id="arriveID" name="ArrvStationID" style="display: none">
</div>
<div class="box">
<input type="text" id="datepicker" value="#DateTime.Now.Date.ToString(" yyyy/MM/dd ")" name="DeptDate">
</div>
<div class="box">
<input type="text" id="timepicker" name="time">
</div>
<div class="box"><button type="submit" name="Submit" class="go_button">Go</button></div>
</div>
</div>
You could use flex box.
try something out like the following:
FIDDLE
https://jsfiddle.net/pcehxx7f/16/
HTML
<div class="container">
<div class="box">
<input type="text">
</div>
<div class="box">
<input type="text">
</div>
<div class="box">
<input type="text">
</div>
<div class="box">
<input type="text">
</div>
</div>
CSS
.container {
display: flex;
justify-content: space-between;
}
.box {
padding: 0 10px;
}
.box input {
width: 100%;
}
I would use the next hack...
.box_container:after{
content:'';
display:block;
clear:both;
}
This adds a last element in your container, using the clear property, this is happening because the float element don't take space in its container..
.info {
background-color: black;
padding: 20px 20px 40px 20px;
margin-bottom: 10%;
}
.go_button {
width: 175px;
background-color: #01C3A7;
border: none;
cursor: pointer;
border-radius: 0.429rem;
color: #FFFFFF;
font-family: Circular,Helvetica,Arial,sans-serif;
font-size: 1.429rem;
font-weight: bold;
letter-spacing: 0px;
padding: 3px;
}
.box {
float: left;
}
.box_container:after{
content:'';
display:block;
clear:both;
}
<div class="info">
<div class="box_container">
<div class="box">
<input type="text" placeholder="Departure Station" id="depart">
<input type="hidden" id="departID" name="DeptStationID" style="display: none">
</div>
<div class="box">
<input type="text" placeholder="Arrival Station" id="arrive">
<input type="hidden" id="arriveID" name="ArrvStationID" style="display: none">
</div>
<div class="box">
<input type="text" id="datepicker" value="#DateTime.Now.Date.ToString("yyyy/MM/dd")" name="DeptDate">
</div>
<div class="box">
<input type="text" id="timepicker" name="time">
</div>
<div class="box"><button type="submit" name="Submit" class="go_button">Go</button></div>
</div>
</div>
Use Clearfix to automatically close elemts float.
How it works is well described in this question:
What is a clearfix?
But much better solution is to use flexbox.
Nice flexbox guide can be found on css-tricks.com
Problem is that the footer's text is left aligned on this page but not on any others using identical code. I went step by step commenting out each section and it is the map img that is causing this issue. I can solve this by setting the footer to clear right but that seems to completely mess up the height of the footer. I have included a couple of screen prints to help demonstrate what I mean.
#container {
background-image: url(..//Images/backgroundPic.jpg);
background-repeat: no-repeat;
margin-left: auto;
margin-right: auto;
width: 1000px;
border-style: ridge;
border-width: 5px;
}
h1,
h2 {
text-decoration: underline;
}
p {
font-weight: bold;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: medium;
background-color: #F1EBEB;
}
/* Header */
#top {
padding: 0px;
margin: 0px;
background-color: white;
background-image: url(../images/tutorteam.png);
height: 50px;
width: 1000px;
font-size: 1em;
}
#top img {
padding-top: 5px;
padding-left: 5px;
padding-bottom: 5px;
padding-right: 5px;
}
#details {
display: table;
padding: 10px;
}
#details p {
display: table-cell;
vertical-align: top;
padding: 3px;
}
div.tablerow {
display: table-row
}
div.tablerow p:first-child {
text-align: right;
}
#logo {
float: right;
margin-left: 4px;
margin-top: 2px;
}
#back {
float: left;
margin-left: 40px;
margin-top: 2px;
}
#main {
padding: 10px;
margin-top: 20px;
margin-left: 20px;
margin-right: 20px;
background-color: white;
}
#tableContainer {
display: table;
margin-left: auto;
margin-right: auto;
border-spacing: 10px;
font-size: 0.25em;
}
#footer {
display: table-row;
}
#tableCell {
display: table-cell;
vertical-align: top;
}
#dubaiMap {
float: right;
position: relative;
right: 20px;
top: -200px;
}
#signUp {
margin-left: 110px;
margin-bottom: 100px;
border: 0px;
padding: 0px;
height: 90px;
}
#submit {
float: right;
position: relative;
bottom: 60px;
left: 420px;
margin-left: 20px;
background-color: #4CAF50;
/* Green */
border: 2px solid black;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
font-size: 16px;
}
textarea {
float: right;
position: relative;
bottom: 250px;
right: 175px;
border: 3px solid #4CAF50;
font-size: 14px
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Sign Up</title>
<link type="text/css" rel="stylesheet" href="login.css">
</head>
<body>
<div id="container">
<section id="top">
<a href="../index.html">
<img id="back" src="../images/back.png" height="40px">
</a>
<img id="logo" src="../images/tutorTeamLogo.png" height="40px">
</section>
<section id="main">
<p>Are you a tutor or customer? please select the relevant option.</p>
<form>
<select name="user">
<option value="Customer">Customer</option>
<option value="Tutor">Tutor</option>
</select>
</form>
<form action="tutorSignUp.php" method="POST">
<p>Please complete to sign up.</p>
<section id="details">
<div class="tablerow">
<p>First name:</p>
<p>
<input type="text" name="firstName" value="">
</p>
</div>
<div class="tablerow">
<p>Last name:</p>
<p>
<input type="text" name="lastName" value="">
</p>
</div>
<div class="tablerow">
<p>Address:</p>
<p>
<input type="text" name="address" value="">
</p>
</div>
<div class="tablerow">
<p>city:</p>
<p>
<input type="text" name="city" value="">
</p>
</div>
<div class="tablerow">
<p>Zip:</p>
<p>
<input type="text" name="zip" value="">
</p>
</div>
<div class="tablerow">
<p>Telephone:</p>
<p>
<input type="tel" name="telephone" value="">
</p>
</div>
</section>
<img src="../Images/dubaiZones.png" id="dubaiMap">
<p>Tutoring level</p>
<select name="level">
<option value="Pre School">Pre School</option>
<option value="Primary School">Primary</option>
<option value="GCSE">GCSE</option>
<option value="A level">A Level</option>
<option value="Undergraduate">Undergraduate</option>
<option value="Post Graduate">Post Graduate</option>
</select>
<p>Subject specialism(s)</p>
<input type="checkbox" name="subject" value="English">English
<br>
<input type="checkbox" name="subject" value="Maths">Maths
<br>
<input type="checkbox" name="subject" value="Physics">Physics
<br>
<input type="checkbox" name="subject" value="Chemistry">Chemistry
<br>
<input type="checkbox" name="subject" value="Biology">Biology
<br>
<input type="checkbox" name="subject" value="History">History
<br>
<input type="checkbox" name="subject" value="Geography">Geography
<br>
<input type="checkbox" name="subject" value="Religious Studies">R.E.
<br>
<input type="checkbox" name="subject" value="French">French
<br>
<input type="checkbox" name="subject" value="German">German
<br>
<input type="checkbox" name="subject" value="Spanish">Spanish
<br>
<input type="checkbox" name="subject" value="Computing">Computing
<br>
<input type="checkbox" name="subject" value="Business">Business
<br>
<input type="checkbox" name="subject" value="Economics">Economics
<br>
<input type="checkbox" name="subject" value="Classics">Classics
<br>
<br>
<textarea id="textArea" name="comments" rows="10" cols="48">Additional Information...</textarea>
<input type="submit" value="Sign Up" id="submit">
</form>
</section>
<footer>
<table id="tableContainer">
<tr id="footer">
<td id="tableCell">Website design and coding provided by Technology in Learning 2016 Copyright Technology in Learning
<img id="til" src="../Images/company.png" height="12" width="12">
</td>
</tr>
</table>
</footer>
</div>
</body>
</html>
I don't undestand the need of using a table to display a single line of text.
You juste need to use a paragraph with text-align: center;
.text-center {
text-align: center;
}
<footer id="footer">
<p class="text-center">Website design and coding provided by Technology in Learning 2016 Copyright Technology in Learning
<img id="til" src="../Images/company.png" height="12" width="12">
</p>
</footer>
Plus I think your issue is du to the use of the table. I believe by default table cell align text on the left, and I didn't see any CSS rule to change that in your code.
I created a form and I want the content of the form to all be left-aligned. The inputs and paragraphs in the form end up on top of each other when I use float: left; so I am trying to figure out how to properly implement this so they are all neatly stacked on top of one another.
The header is in a perfect position as is. I only want the form to be left aligned.
* {
box-sizing: border-box;
}
body {
background-color: black;
margin-left: 20%;
margin-right: 20%;
margin-top: 3%;
}
button {
background-color: white;
border: none;
color: black;
float: left;
font-family: Gilroy-Bold;
font-size: 57px;
height: 110px;
margin-bottom: 40px;
margin-top: 40px;
width: 300px;
}
button:hover {
background-color: lightgray;
}
form {
float: left;
}
textarea {
float: left;
font-family: Gilroy;
font-size: 25px;
height: 400px;
padding-left: 10px;
padding-top: 5px;
width: 600px;
}
#font-face {
font-family: Gilroy;
color: white;
src: typefaces/gilroy-bold.ttf (gilroy-bold.ttf);
}
form {
font-family: Gilroy;
padding-top: 20px;
padding-bottom: 40px;
}
h1 {
color: white;
font-family: Gilroy-Bold;
font-size: 95px;
margin-bottom: 0px;
margin-top: 0px;
text-align: center;
}
hr {
border: 0;
border-bottom: 1px solid white;
border-top: 12px solid white;
width: 760px;
}
input {
float: left;
font-family: Gilroy;
font-size: 25px;
padding-left: 5px;
height: 50px;
width: 500px;
}
p{
color: white;
float: left;
font-family: Gilroy-Bold;
font-size: 30px;
}
<DOCTYPE! html>
<html>
<head>
<title>1520 Sedgwick Avenue - Sign The Petition</title>
<link href="css/form.css" rel="stylesheet"/>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="petition.js"></script>
</head>
<body>
<header>
<hr>
<h1>SIGN THE PETITION</h1>
<hr>
</header>
<div class="col-sm-6 col-sm-offset-3">
<form action="petition.php" method="POST">
<p>FIRST NAME</p>
<div id="first-name-group" class="form-group">
<label for="first-name">First Name</label>
<input type="text" class="form-control" name="first-name" placeholder="John">
</div>
<p>LAST NAME</p>
<div id="last-name-group" class="form-group">
<label for="last-name">Last Name</label>
<input type="text" class="form-control" name="last-name" placeholder="Smith">
</div>
<p>EMAIL</p>
<div id="email-group" class="form-group">
<label for="email">Email</label>
<input type="text" class="form-control" name="email" placeholder="jsmith#gmail.com">
</div>
<p>COUNTRY</p>
<div id="country-group" class="form-group">
<label for="country">Country</label>
<input type="text" class="form-control" name="country" placeholder="United States">
</div>
<p>STREET ADDRESS</p>
<div id="street-address-group" class="form-group">
<label for="street-address">Street Address</label>
<input type="text" class="form-control" name="street-address" placeholder="123 Brick Lane">
</div>
<p>ZIP CODE</p>
<div id="zip-code-group" class="form-group">
<label for="zip-code">Zip Code</label>
<input type="text" class="form-control" name="zip-code" placeholder="12345">
</div>
<p>COMMENT (OPTIONAL)</p>
<div id="comment-group" class="form-group">
<label for="comment">Comment</label>
<textarea rows "4" cols = "50" type="text" class="form-control" name="comment" placeholder="I'm signing because..."></textarea>
</div>
<button type="submit" class="btn btn-success">SUBMIT</button>
</form>
</div>
</body>
</html>
Cleared form-group class. Because you are floating the inputs to left. The wrapper of it which is form-group must clear itself so that the next div can come after it.
I also made paragraph tag to take 100% width.
Also note that for refers to the name attribute in the <input> tag in your code. It should refer to the id attribute. [ Mentioned by - Roy_Dorsthorst]
* {
box-sizing: border-box;
}
body {
background-color: black;
margin-left: 20%;
margin-right: 20%;
margin-top: 3%;
}
button {
background-color: white;
border: none;
color: black;
float: left;
font-family: Gilroy-Bold;
font-size: 57px;
height: 110px;
margin-bottom: 40px;
margin-top: 40px;
width: 300px;
}
.form-group:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
button:hover {
background-color: lightgray;
}
form {
float: left;
}
textarea {
float: left;
font-family: Gilroy;
font-size: 25px;
height: 400px;
padding-left: 10px;
padding-top: 5px;
width: 600px;
}
#font-face {
font-family: Gilroy;
color: white;
src: typefaces/gilroy-bold.ttf (gilroy-bold.ttf);
}
form {
font-family: Gilroy;
padding-top: 20px;
padding-bottom: 40px;
}
h1 {
color: white;
font-family: Gilroy-Bold;
font-size: 95px;
margin-bottom: 0px;
margin-top: 0px;
text-align: center;
}
hr {
border: 0;
border-bottom: 1px solid white;
border-top: 12px solid white;
width: 760px;
}
input {
float: left;
font-family: Gilroy;
font-size: 25px;
padding-left: 5px;
height: 50px;
width: 500px;
}
p{
color: white;
float: left;
font-family: Gilroy-Bold;
font-size: 30px;
width: 100%;
}
<DOCTYPE! html>
<html>
<head>
<title>1520 Sedgwick Avenue - Sign The Petition</title>
<link href="css/form.css" rel="stylesheet"/>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="petition.js"></script>
</head>
<body>
<header>
<hr>
<h1>SIGN THE PETITION</h1>
<hr>
</header>
<div class="col-sm-6 col-sm-offset-3">
<form action="petition.php" method="POST">
<p>FIRST NAME</p>
<div id="first-name-group" class="form-group">
<label for="first-name">First Name</label>
<input type="text" class="form-control" id="first-name" name="first-name" placeholder="John">
</div>
<p>LAST NAME</p>
<div id="last-name-group" class="form-group">
<label for="last-name">Last Name</label>
<input type="text" class="form-control" id="last-name" name="last-name" placeholder="Smith">
</div>
<p>EMAIL</p>
<div id="email-group" class="form-group">
<label for="email">Email</label>
<input type="text" class="form-control" id="email" name="email" placeholder="jsmith#gmail.com">
</div>
<p>COUNTRY</p>
<div id="country-group" class="form-group">
<label for="country">Country</label>
<input type="text" class="form-control" id="country" name="country" placeholder="United States">
</div>
<p>STREET ADDRESS</p>
<div id="street-address-group" class="form-group">
<label for="street-address">Street Address</label>
<input type="text" class="form-control" id="street-address" name="street-address" placeholder="123 Brick Lane">
</div>
<p>ZIP CODE</p>
<div id="zip-code-group" class="form-group">
<label for="zip-code">Zip Code</label>
<input type="text" class="form-control" id="zip-code" name="zip-code" placeholder="12345">
</div>
<p>COMMENT (OPTIONAL)</p>
<div id="comment-group" class="form-group">
<label for="comment">Comment</label>
<textarea rows "4" cols = "50" type="text" class="form-control" id="comment" name="comment" placeholder="I'm signing because..."></textarea>
</div>
<button type="submit" class="btn btn-success">SUBMIT</button>
</form>
</div>
</body>
</html>