Skip to content

Commit 2a11abb

Browse files
committed
Styled contact form errors to not bork the layout of the form
1 parent 98f4f38 commit 2a11abb

File tree

2 files changed

+70
-19
lines changed

2 files changed

+70
-19
lines changed

pythonkc_site/static/screen.css

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,55 @@ section.resources{
265265
font-size: 80%;
266266
}
267267

268-
.contact-name { width: 155px; border-color: #87CDED; }
269-
.contact-email { width: 200px; border-color: #87CDED; }
270-
.contact-message { width: 521px; border-color: #87CDED;
271-
font: 13px 'Helvetica Neue',Arial,Helvetica,sans-serif normal; }
272-
.contact-submit { color: #1B82B3; }
273-
.contact-form .errorlist { color: #FF0000; display: inline; width: 155px; }
274-
.contact-form .errorlist li { display: inline; width: 155px; }
268+
/* The containers are meant to create columns that field errors can fill
269+
vertically while the column-width is maintained. */
270+
.contact-name {
271+
width: 157px;
272+
border-color: #87CDED;
273+
}
274+
.name-container {
275+
width: 157px;
276+
float: left;
277+
padding-right: 3px;
278+
margin-right: 1px;
279+
}
280+
.contact-email {
281+
width: 200px;
282+
border-color: #87CDED;
283+
}
284+
.email-container {
285+
width: 200px;
286+
float: left;
287+
}
288+
.contact-message {
289+
width: 522px;
290+
border-color: #87CDED;
291+
font: 13px 'Helvetica Neue',Arial,Helvetica,sans-serif normal;
292+
}
293+
.message-container {
294+
width: 522px;
295+
float: left;
296+
padding-right: 3px;
297+
}
298+
.contact-submit {
299+
color: #1B82B3;
300+
}
301+
.contact-form .errorlist {
302+
color: #FFAFAF;
303+
display: inline;
304+
margin-bottom: 6px;
305+
}
275306

276-
.contact-form input::-webkit-input-placeholder { background-color: #1B82B3; color: #87CDED; }
277-
.contact-form textarea::-webkit-input-placeholder { background-color: #1B82B3; color: #87CDED; }
278-
.contact-form *:-moz-placeholder { background-color: #1B82B3; color: #87CDED; }
307+
.contact-form *:-moz-placeholder {
308+
background-color: #1B82B3;
309+
color: #87CDED;
310+
}
311+
/* Combining these as *::-webkit-input-placeholder didn't seem to work...*/
312+
.contact-form input::-webkit-input-placeholder {
313+
background-color: #1B82B3;
314+
color: #87CDED;
315+
}
316+
.contact-form textarea::-webkit-input-placeholder {
317+
background-color: #1B82B3;
318+
color: #87CDED;
319+
}

pythonkc_site/templates/index.html

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,25 @@ <h1>FOLLOW US</h1>
127127
enctype="application/x-www-form-urlencoded"
128128
class="contact-form">
129129
{% csrf_token %}
130-
{{ form.first_name }}
131-
{{ form.last_name }}
132-
{{ form.email }}
133-
{{ form.first_name.errors }}
134-
{{ form.last_name.errors }}
135-
{{ form.email.errors }}
136-
{{ form.message }}
137-
{{ form.message.errors }}
138-
<input type="submit" value="SUBMIT" class="contact-submit" />
130+
<span class="name-container">
131+
{{ form.first_name }}
132+
{{ form.first_name.errors }}
133+
</span>
134+
<span class="name-container">
135+
{{ form.last_name }}
136+
{{ form.last_name.errors }}
137+
</span>
138+
<span class="email-container">
139+
{{ form.email }}
140+
{{ form.email.errors }}
141+
</span>
142+
<span class="message-container">
143+
{{ form.message }}
144+
{{ form.message.errors }}
145+
</span>
146+
<div>
147+
<input type="submit" value="SUBMIT" class="contact-submit" />
148+
</div>
139149
</form>
140150
</div>
141151
</section>

0 commit comments

Comments
 (0)