I need to do the same as here:
http://deinehelfer24.de/renovierungen/
As I understand it, this is done on contact form 7, but how are the images and multiple selections implemented?
I feel generous today, simpe example ho you can style labels
https://jsfiddle.net/Beneris/65mdtpo3/28/
HTML
<form>
<div class="input-group">
<div class="input-wrap">
<input type="radio" name="group1" id="group1-1" value="1">
<label for="group1-1">
<figure><img src="http://placekitten.com/g/100/100"><h3>Radio 1</h3></figure>
</label>
</div>
<div class="input-wrap">
<input type="radio" name="group1" id="group1-2" value="2">
<label for="group1-2">
<figure><img src="http://placekitten.com/g/100/100"><h3>Radio 2</h3></figure>
</label>
</div>
<div class="input-wrap">
<input type="radio" name="group1" id="group1-3" value="3">
<label for="group1-3">
<figure><img src="http://placekitten.com/g/100/100"><h3>Radio 3</h3></figure>
</label>
</div>
</div>
<div class="input-group">
<div class="input-wrap to-toggle 1 3">
<input type="checkbox" name="group2" id="group2-1" value="1">
<label for="group2-1">
<figure><img src="http://placekitten.com/g/100/100"><h3>checkbox 1</h3></figure>
</label>
</div>
<div class="input-wrap to-toggle 1 2">
<input type="checkbox" name="group2" id="group2-2" value="2">
<label for="group2-2">
<figure><img src="http://placekitten.com/g/100/100"><h3>checkbox 2</h3></figure>
</label>
</div>
<div class="input-wrap to-toggle 1 2 3">
<input type="checkbox" name="group2" id="group2-3" value="3">
<label for="group2-3">
<figure><img src="http://placekitten.com/g/100/100"><h3>checkbox 3</h3></figure>
</label>
</div>
</div>
</form>
CSS
.radio-group {
display:block;
}
.input-group .input-wrap{
display:inline-block;
vertical-align: top;
padding: 10px;
}
label figure {
background-color: #ccc;
padding: 5px 10px;
border-radius: 0 0 5px 5px;
cursor: pointer;
}
figure h3 {
text-align: center;
}
.input-group input:checked ~ label figure {
background-color: red;
}
.input-wrap input {
display:none;
}
JS
$('.to-toggle').hide();
$('input[name=group1]').on('change', function(){
var val = $(this).val();
$('.to-toggle').hide();
$('.to-toggle input').prop('checked', false);
$('.to-toggle.' + val).show();
//alert(val);
});
Related
I'm working on an online rubric program, and I've tried just about everything I know without any luck. What I am trying to do is make each column in the rubric the same width and dynamically resize the height. Since there are 5 columns for each row, each column should be aprox 20% width of the parent. The tricky part comes with the height of each item. Since there will be varying text lengths inside each item, every item in the row should resize to the height of the longest item from that row.
I'm using flex right now, and I've tried using flex: 1 1 0px and flex-grow: 1; inside the .tile without luck. I have also tried using CSS grid, where I am able to achieve the equal width, but then the height requirement gets all wonky.
For visual people, the end result should look like this.
Any advice is appreciated.
.print {display: none}
body {margin: 0}
#title {
max-width: 1880px;
text-align: center;
font-size: 35px}
#title select {
font-size: 35px;
appearance: none;
outline: none;
border: none;
-webkit-appearance: none;
background-color: transparent}
/* --------[RUBRIC]-------- */
#rubric {margin: 10px 25px 55px 25px;}
#rubric textarea {
width: 100%;
margin-bottom: 20px;
border: 1px solid black;
box-sizing: border-box;}
section {display: flex;}
.tile {
flex: 1 1 0px;
box-sizing: border-box;
padding: 5px 10px 20px 10px;
border-radius: 2px;
border: 1px solid black;
font-size: 0.90rem;
text-align: center}
#rubric input[type=radio] {display: none}
#rubric input:checked + label .tile {background-color: #B488E7}
<form action='rubric.int.php' method='post'>
<div id='title'>
Research & Inquiry
<select name='usid' onchange='enableButton()' required>
<option value='' disabled hidden>____________</option>
<option value='11'>John Doe</option>
</select>
<h2 class='print'>August 8th, 2021</h2>
<hr class='print'>
</div>
<div id='rubric'>
<section>
<div class='category'></div>
<div class='category'>Beginning</div>
<div class='category'>Approaching</div>
<div class='category'>Meeting</div>
<div class='category'>Exceeding</div>
</section>
<section>
<input type='radio' id='4' disabled>
<label for='4'>
<div class='tile'>Inquiry<br><i>6.R.1</i></div>
</label>
<input type='radio' id='b_6.R.1' name='score[6.R.1]' value='1'>
<label for='b_6.R.1'>
<div class='tile'>Student can choose a topic but may need help <b>constructing questions</b> and <b>using resources</b> to find information.</div>
</label>
<input type='radio' id='a_6.R.1' name='score[6.R.1]' value='2'>
<label for='a_6.R.1'>
<div class='tile'>Student can ask their own questions but may need help <b>finding information</b>on their topic.</div>
</label>
<input type='radio' id='m_6.R.1' name='score[6.R.1]' value='3'>
<label for='m_6.R.1'>
<div class='tile'>Student can utilize their own viable research questions to find information about a specific topic.</div>
</label>
<input type='radio' id='e_6.R.1' name='score[6.R.1]' value='4'>
<label for='e_6.R.1'>
<div class='tile'>Student meeting all requirements with a degree of excellency. </div>
</label>
</section>
<section>
<input type='radio' id='4' disabled>
<label for='4'>
<div class='tile'>Recording Info<br><i>6.R.2</i></div>
</label>
<input type='radio' id='b_6.R.2' name='score[6.R.2]' value='1'>
<label for='b_6.R.2'>
<div class='tile'>Student can take notes using a provided template or organizer <b>with help</b> from the teacher.</div>
</label>
<input type='radio' id='a_6.R.2' name='score[6.R.2]' value='2'>
<label for='a_6.R.2'>
<div class='tile'>Student can take notes provided by a template or organizer <b>AND</b> can <b>organize</b> those notes for a specific purpose with help from the teacher.</div>
</label>
<input type='radio' id='m_6.R.2' name='score[6.R.2]' value='3'>
<label for='m_6.R.2'>
<div class='tile'>Student can take and organize notes from various print and/or digital sources.</div>
</label>
<input type='radio' id='e_6.R.2' name='score[6.R.2]' value='4'>
<label for='e_6.R.2'>
<div class='tile'>Student meeting all requirements with a degree of excellency. </div>
</label>
</section>
<section>
<input type='radio' id='4' disabled>
<label for='4'>
<div class='tile'>Reliability<br><i>6.R.3</i></div>
</label>
<input type='radio' id='b_6.R.3' name='score[6.R.3]' value='1'>
<label for='b_6.R.3'>
<div class='tile'>Student can evaluate the importance of information gathered but may need help establishing credibility.</div>
</label>
<input type='radio' id='a_6.R.3' name='score[6.R.3]' value='2'>
<label for='a_6.R.3'>
<div class='tile'>Students can evaluate the importance <b>AND credibility</b> of information gathered with help from a teacher. </div>
</label>
<input type='radio' id='m_6.R.3' name='score[6.R.3]' value='3'>
<label for='m_6.R.3'>
<div class='tile'>Student can evaluate the relevance and reliability of information gathered.</div>
</label>
<input type='radio' id='e_6.R.3' name='score[6.R.3]' value='4'>
<label for='e_6.R.3'>
<div class='tile'>Student meeting all requirements with a degree of excellency. </div>
</label>
</section>
<input type='hidden' name='standard' value='4'>
<input type='hidden' name='ucid' value='1'>
<textarea placeholder='Add comments..' name='comment'></textarea>
<p class='print'>Comments:</p>
</div>
<div id='controls' class='center'>
<button class='button grey-btn' disabled>Record Progress</button>
</div>
</form>
I think this is the perfect use-case for CSS Grid. I would recommend making the <section> a grid and using something like repeat(5, 20%) or explicitly use 20% 20% 20% 20% 20% for your grid-template-columns definition. You might also use a combination of repeat() and minmax() for column generation when building out responsive grids.
Lastly, just make sure to give each .tile a height of 100% so they occupy all of the vertical space in each grid item.
.print {display: none}
body {margin: 0}
#title {
max-width: 1880px;
text-align: center;
font-size: 35px}
#title select {
font-size: 35px;
appearance: none;
outline: none;
border: none;
-webkit-appearance: none;
background-color: transparent}
/* --------[RUBRIC]-------- */
#rubric {margin: 10px 25px 55px 25px;}
#rubric textarea {
width: 100%;
margin-bottom: 20px;
border: 1px solid black;
box-sizing: border-box;}
section {
display: grid;
/* grid-template-columns: 20% 20% 20% 20% 20%; */
grid-template-columns: repeat(5, 20%);
gap: 0;
}
.tile {
box-sizing: border-box;
height: 100%;
overflow: auto;
padding: 5px 10px 20px 10px;
border-radius: 2px;
border: 1px solid black;
font-size: 0.90rem;
text-align: center}
#rubric input[type=radio] {display: none}
#rubric input:checked + label .tile {background-color: #B488E7}
<form action='rubric.int.php' method='post'>
<div id='title'>
Research & Inquiry
<select name='usid' onchange='enableButton()' required>
<option value='' disabled hidden>____________</option>
<option value='11'>John Doe</option>
</select>
<h2 class='print'>August 8th, 2021</h2>
<hr class='print'>
</div>
<div id='rubric'>
<section>
<div class='category'></div>
<div class='category'>Beginning</div>
<div class='category'>Approaching</div>
<div class='category'>Meeting</div>
<div class='category'>Exceeding</div>
</section>
<section>
<input type='radio' id='4' disabled>
<label for='4'>
<div class='tile'>Inquiry<br><i>6.R.1</i></div>
</label>
<input type='radio' id='b_6.R.1' name='score[6.R.1]' value='1'>
<label for='b_6.R.1'>
<div class='tile'>Student can choose a topic but may need help <b>constructing questions</b> and <b>using resources</b> to find information.</div>
</label>
<input type='radio' id='a_6.R.1' name='score[6.R.1]' value='2'>
<label for='a_6.R.1'>
<div class='tile'>Student can ask their own questions but may need help <b>finding information</b>on their topic.</div>
</label>
<input type='radio' id='m_6.R.1' name='score[6.R.1]' value='3'>
<label for='m_6.R.1'>
<div class='tile'>Student can utilize their own viable research questions to find information about a specific topic.</div>
</label>
<input type='radio' id='e_6.R.1' name='score[6.R.1]' value='4'>
<label for='e_6.R.1'>
<div class='tile'>Student meeting all requirements with a degree of excellency. </div>
</label>
</section>
<section>
<input type='radio' id='4' disabled>
<label for='4'>
<div class='tile'>Recording Info<br><i>6.R.2</i></div>
</label>
<input type='radio' id='b_6.R.2' name='score[6.R.2]' value='1'>
<label for='b_6.R.2'>
<div class='tile'>Student can take notes using a provided template or organizer <b>with help</b> from the teacher.</div>
</label>
<input type='radio' id='a_6.R.2' name='score[6.R.2]' value='2'>
<label for='a_6.R.2'>
<div class='tile'>Student can take notes provided by a template or organizer <b>AND</b> can <b>organize</b> those notes for a specific purpose with help from the teacher.</div>
</label>
<input type='radio' id='m_6.R.2' name='score[6.R.2]' value='3'>
<label for='m_6.R.2'>
<div class='tile'>Student can take and organize notes from various print and/or digital sources.</div>
</label>
<input type='radio' id='e_6.R.2' name='score[6.R.2]' value='4'>
<label for='e_6.R.2'>
<div class='tile'>Student meeting all requirements with a degree of excellency. </div>
</label>
</section>
<section>
<input type='radio' id='4' disabled>
<label for='4'>
<div class='tile'>Reliability<br><i>6.R.3</i></div>
</label>
<input type='radio' id='b_6.R.3' name='score[6.R.3]' value='1'>
<label for='b_6.R.3'>
<div class='tile'>Student can evaluate the importance of information gathered but may need help establishing credibility.</div>
</label>
<input type='radio' id='a_6.R.3' name='score[6.R.3]' value='2'>
<label for='a_6.R.3'>
<div class='tile'>Students can evaluate the importance <b>AND credibility</b> of information gathered with help from a teacher. </div>
</label>
<input type='radio' id='m_6.R.3' name='score[6.R.3]' value='3'>
<label for='m_6.R.3'>
<div class='tile'>Student can evaluate the relevance and reliability of information gathered.</div>
</label>
<input type='radio' id='e_6.R.3' name='score[6.R.3]' value='4'>
<label for='e_6.R.3'>
<div class='tile'>Student meeting all requirements with a degree of excellency. </div>
</label>
</section>
<input type='hidden' name='standard' value='4'>
<input type='hidden' name='ucid' value='1'>
<textarea placeholder='Add comments..' name='comment'></textarea>
<p class='print'>Comments:</p>
</div>
<div id='controls' class='center'>
<button class='button grey-btn' disabled>Record Progress</button>
</div>
</form>
Edit: Your source from pastebin was missing a closing </html> tag.
<body>
<title>Presentations Rubric</title>
<link rel='stylesheet' href='https://classcolonies.com/resources/style.css'>
<form id='rubric' action='rubric.int.php' method='post'>
<div id='title'>
Presentations
<select name='usid' onchange='enableButton()' required>
<option value='' disabled hidden>____________</option>
<option value='11'>John Doe</option>
</select>
<h2 class='print'>August 8th, 2021</h2>
<hr class='print'>
</div>
<div id='rubric'>
<section>
<div class='category'></div>
<div class='category'>Beginning</div>
<div class='category'>Approaching</div>
<div class='category'>Meeting</div>
<div class='category'>Exceeding</div>
</section>
<section>
<input type='radio' id='5' disabled>
<label for='5'>
<div class='tile'>
Using Technology
<br>
<i>7.W.1</i>
</div>
</label>
<input type='radio' id='b_7.W.1' name='score[7.W.1]' value='1'>
<label for='b_7.W.1'>
<div class='tile'>
Student
<b>needs guidance and support</b>
to create multimodal content that effectively communicates an idea using appropriate technology and media.
</div>
</label>
<input type='radio' id='a_7.W.1' name='score[7.W.1]' value='2'>
<label for='a_7.W.1'>
<div class='tile'>
Student
<b>attempts</b>
to create multimodal content that effectively communicates an idea using appropriate technology and media.
</div>
</label>
<input type='radio' id='m_7.W.1' name='score[7.W.1]' value='3'>
<label for='m_7.W.1'>
<div class='tile'>Student will create multimodal content that effectively communicates an idea using appropriate technology and media.</div>
</label>
<input type='radio' id='e_7.W.1' name='score[7.W.1]' value='4'>
<label for='e_7.W.1'>
<div class='tile'>Student meeting all requirements with a degree of excellency. </div>
</label>
</section>
<section>
<input type='radio' id='5' disabled>
<label for='5'>
<div class='tile'>
Presentation Creation
<br>
<i>7.W.2</i>
</div>
</label>
<input type='radio' id='b_7.W.2' name='score[7.W.2]' value='1'>
<label for='b_7.W.2'>
<div class='tile'>
Student
<b>needs guidance and support</b>
to create presentations that integrate visual displays and other multimedia to enrich the presentation.
</div>
</label>
<input type='radio' id='a_7.W.2' name='score[7.W.2]' value='2'>
<label for='a_7.W.2'>
<div class='tile'>
Student
<b>attempts</b>
to create presentations that integrate visual displays and other multimedia to enrich the presentation.
</div>
</label>
<input type='radio' id='m_7.W.2' name='score[7.W.2]' value='3'>
<label for='m_7.W.2'>
<div class='tile'>Student will create presentations that integrate visual displays and other multimedia to enrich the presentation.
</div>
</label>
<input type='radio' id='e_7.W.2' name='score[7.W.2]' value='4'>
<label for='e_7.W.2'>
<div class='tile'>Student meeting all requirements with a degree of excellency.
</div>
</label>
</section>
<section>
<input type='radio' id='5' disabled>
<label for='5'>
<div class='tile'>
Presentation Skills
<br>
<i>1.W.1</i>
</div>
</label>
<input type='radio' id='b_1.W.1' name='score[1.W.1]' value='1'>
<label for='b_1.W.1'>
<div class='tile'>
Student attempts to give
<b>simple</b>
presentations in a group or individually, organizing information and determining appropriate content for audience with
<b>full guidance and support</b>
.
</div>
</label>
<input type='radio' id='a_1.W.1' name='score[1.W.1]' value='2'>
<label for='a_1.W.1'>
<div class='tile'>
Student gives presentations in a group or individually, organizing information and determining appropriate content for audience with
<b>some guidance and support</b>
.
</div>
</label>
<input type='radio' id='m_1.W.1' name='score[1.W.1]' value='3'>
<label for='m_1.W.1'>
<div class='tile'>Student give presentations in a group or individually, organizing information and determining appropriate content for audience.</div>
</label>
<input type='radio' id='e_1.W.1' name='score[1.W.1]' value='4'>
<label for='e_1.W.1'>
<div class='tile'>Student meeting all requirements with a degree of excellency. </div>
</label>
</section>
<input type='hidden' name='standard' value='5'>
<input type='hidden' name='ucid' value='1'>
<textarea placeholder='Add comments..' name='comment'></textarea>
<p class='print'>Comments:</p>
</div>
<div id='controls'>
<button class='button grey-btn' disabled>Record Progress</button>
</div>
</form>
</body>
</html>
<style>
.print {
display: none
}
body {
margin: 0
}
#title {
padding: 20px 0px;
text-align: center;
font-size: 35px
}
#title select {
font-size: 35px;
appearance: none;
outline: none;
border: none;
-webkit-appearance: none;
background-color: transparent
}
/* --------[RUBRIC]-------- */
#rubric {
margin: 10px 25px 0px 25px;
}
#rubric textarea {
width: 100%;
border: 1px solid black;
box-sizing: border-box;
}
section {
display: grid;
grid-template-columns: repeat(5, 20%);
gap: 0;
}
.tile {
box-sizing: border-box;
height: 100%;
overflow: auto;
padding: 5px 10px 20px 10px;
border-radius: 2px;
border: 1px solid black;
font-size: 0.90rem;
text-align: center
}
.tile:hover:not(.category) {
background-color: #D4BBF1;
transform: scale(1.03);
}
.category {
font-size: 1.1rem;
font-weight: bold;
text-align: center;
}
section input[type=radio] {
display: none
}
section input:checked + label .tile {
background-color: #B488E7
}
#controls {
margin-top: 20px;
padding-bottom: 40px;
display: flex;
justify-content: center;
}
/* --------[PRINT]-------- */
.print {
display: none
}
#media print {
body {
margin: 10px
}
.print {
display: block
}
select {
display: none
}
h2 {
margin: 0;
text-align: center;
font-size: 20px
}
.category {
padding-top: 50px;
}
.tile {
font-size: 12px !important;
}
textarea {
display: none
}
.center {
display: none
}
}
</style>
All you have to do is to give display:flex for the same height, flex-direction: column to be neat, and flex: 1 1 0px so that they are the same width (20% of the screen) to each child of the section (using section * to select all children of the section).
.print {display: none}
body {margin: 0}
#title {
max-width: 1880px;
text-align: center;
font-size: 35px}
#title select {
font-size: 35px;
appearance: none;
outline: none;
border: none;
-webkit-appearance: none;
background-color: transparent}
/* --------[RUBRIC]-------- */
#rubric {margin: 10px 25px 55px 25px;}
#rubric textarea {
width: 100%;
margin-bottom: 20px;
border: 1px solid black;
box-sizing: border-box;}
section {display: flex;}
section * {
display:flex;
flex-direction: column;
flex: 1 1 0px;
}
.tile {
flex: 1 1 0px;
box-sizing: border-box;
padding: 5px 10px 20px 10px;
border-radius: 2px;
border: 1px solid black;
font-size: 0.90rem;
text-align: center}
#rubric input[type=radio] {display: none}
#rubric input:checked + label .tile {background-color: #B488E7}
<form action='rubric.int.php' method='post'>
<div id='title'>
Research & Inquiry
<select name='usid' onchange='enableButton()' required>
<option value='' disabled hidden>____________</option>
<option value='11'>John Doe</option>
</select>
<h2 class='print'>August 8th, 2021</h2>
<hr class='print'>
</div>
<div id='rubric'>
<section>
<div class='category'></div>
<div class='category'>Beginning</div>
<div class='category'>Approaching</div>
<div class='category'>Meeting</div>
<div class='category'>Exceeding</div>
</section>
<section>
<input type='radio' id='4' disabled>
<label for='4'>
<div class='tile'>Inquiry<br><i>6.R.1</i></div>
</label>
<input type='radio' id='b_6.R.1' name='score[6.R.1]' value='1'>
<label for='b_6.R.1'>
<div class='tile'>Student can choose a topic but may need help <b>constructing questions</b> and <b>using resources</b> to find information.</div>
</label>
<input type='radio' id='a_6.R.1' name='score[6.R.1]' value='2'>
<label for='a_6.R.1'>
<div class='tile'>Student can ask their own questions but may need help <b>finding information</b>on their topic.</div>
</label>
<input type='radio' id='m_6.R.1' name='score[6.R.1]' value='3'>
<label for='m_6.R.1'>
<div class='tile'>Student can utilize their own viable research questions to find information about a specific topic.</div>
</label>
<input type='radio' id='e_6.R.1' name='score[6.R.1]' value='4'>
<label for='e_6.R.1'>
<div class='tile'>Student meeting all requirements with a degree of excellency. </div>
</label>
</section>
<section>
<input type='radio' id='4' disabled>
<label for='4'>
<div class='tile'>Recording Info<br><i>6.R.2</i></div>
</label>
<input type='radio' id='b_6.R.2' name='score[6.R.2]' value='1'>
<label for='b_6.R.2'>
<div class='tile'>Student can take notes using a provided template or organizer <b>with help</b> from the teacher.</div>
</label>
<input type='radio' id='a_6.R.2' name='score[6.R.2]' value='2'>
<label for='a_6.R.2'>
<div class='tile'>Student can take notes provided by a template or organizer <b>AND</b> can <b>organize</b> those notes for a specific purpose with help from the teacher.</div>
</label>
<input type='radio' id='m_6.R.2' name='score[6.R.2]' value='3'>
<label for='m_6.R.2'>
<div class='tile'>Student can take and organize notes from various print and/or digital sources.</div>
</label>
<input type='radio' id='e_6.R.2' name='score[6.R.2]' value='4'>
<label for='e_6.R.2'>
<div class='tile'>Student meeting all requirements with a degree of excellency. </div>
</label>
</section>
<input type='hidden' name='standard' value='4'>
<input type='hidden' name='ucid' value='1'>
<textarea placeholder='Add comments..' name='comment'></textarea>
<p class='print'>Comments:</p>
</div>
<div id='controls' class='center'>
<button class='button grey-btn' disabled>Record Progress</button>
</div>
</form>
div input:not(:first-of-type){
display: block;
}
#left_side{
width: 40%
}
label{
width:15em;
display: inline-block;
vertical-align: top;
}
input{
width: 23em;
border-style:solid;
border:1px solid black;
}
.group div{
margin-bottom: -1px;
}
.group input {
margin-bottom: -1px;
box-shadow: none;
background-color: antiquewhite;
}
.get{
width:23em;
display: inline-block;
}
<div class="group">
<div>
<label for="first_name">First Name:</label>
<input type="text" id="first_name" class="get">
</div>
<div>
<label for="last_name">First Name:</label>
<input type="text" id="last_name" class="get">
</div>
</div>
<!--Here is some code with grouped boxes:-->
<div>
<label for="address_1_ln_1">Address 1:</label>
<div class="get">
<input type="text" id="address_1_ln_1">
<input type="text" id="address_1_ln_2">
</div>
</div>
<div>
<label for="address_2_ln_1">Address 2:</label>
<div class="get">
<input type="text" id="address_1_ln_1">
<input type="text" id="address_2_ln_2">
</div>
</div>
<div>
<label for="city">City:</label>
<input type="text" id="city" class="get">
</div>
<div>
<label for="state">State:</label>
<input type="text" id="state" class="get">
</div>
<dive>
<label for="zip">Zip:</label>
<input type="text" id="zip" class="get">
</dive>
How do you make text input of forms overlap borders like border: collapse on a table? By default stacking them one on top of the other has them develop a 2px border between adjacent inputs. Ideally both the borders should merge.
You could do
input {
margin-bottom: -1px;
}
I am having issues trying to make this form responsive. Whenever I make my screen smaller, my form won't resize. I am using bootstrap, but I am not sure how to make that happen. I also don't know how to align "email" label with the other labels.
<html>
<head>
<title>Title</title>
</head>
<style>
#myform {
border: 1px outset #ccc;
background: #fff repeat-x;
padding: 50px;
margin: 20px auto;
width: 500px;
height: 450px;
font-size: 14px;
-moz-border-radius: 4px;
}
#myform h3 {
text-align: left;
margin: 0 0 10px 0;
}
#inputs label,
#inputs input,
#inputs textarea,
#inputs select {
display: block;
width: 300px;
float: left;
margin-bottom: 10px;
}
#inputs input {
height: 40px;
}
#inputs label {
text-align: right;
width: 75px;
padding-right: 20px;
}
#inputs br {
clear: left;
}
#agree {
font-size: 10.5px;
}
</style>
<body>
<div class="container">
<form id="myform" action="#">
<h3>Your Information</h3>
<div id="inputs">
<!-- username -->
<label for="username">Firstname</label>
<br/>
<input id="username" type="text" placeholder="Fullname" /><br />
<!-- password -->
<label for="password">Password</label>
<br/>
<input id="password" type="password" placeholder="Password" />
<br />
<!-- email -->
<label for="email">Email </label>
<br/>
<input id="email" type="text" placeholder="Email" />
</div>
<p>
<button type="button" class="btn btn-primary btn-lg btn-block">
Proceed
</button>
</p>
<label id="agree">
By registering you agree to Elephant's Terms of Service and Privacy Policy.
<input type="checkbox" id="check" title="Required to proceed" />
</label>
</form>
</div>
<body>
</html>
As you already use bootstrap take advantage of bootstrap css classes. Here is official documentation about forms (https://v4-alpha.getbootstrap.com/components/forms/). One of form solution would be:
<form class="form-horizontal">
<fieldset>
<!-- Form Name -->
<legend>Form Name</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="username">username:</label>
<div class="col-md-4">
<input id="username" name="username" type="text" placeholder="Username" class="form-control input-md" required="">
</div>
</div>
<!-- Password input-->
<div class="form-group">
<label class="col-md-4 control-label" for="password">password:</label>
<div class="col-md-4">
<input id="password" name="password" type="password" placeholder="password" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="email">email:</label>
<div class="col-md-4">
<input id="email" name="email" type="text" placeholder="email" class="form-control input-md" required="">
</div>
</div>
<!-- Multiple Checkboxes -->
<div class="form-group">
<label class="col-md-4 control-label" for="checkboxes"></label>
<div class="col-md-4">
<div class="checkbox">
<label for="checkboxes-0">
<input type="checkbox" name="checkboxes" id="checkboxes-0" value="1">
By registering you agree to Elephant's Terms of Service and Privacy Policy.
</label>
</div>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="singlebutton">Single Button</label>
<div class="col-md-4">
<button id="singlebutton" name="singlebutton" class="btn btn-primary">Button</button>
</div>
</div>
</fieldset>
</form>
I see CSS templates like Bootstrap. How do style my form into a div table like below?
With the following HTML:
<form>
<fieldset>
<legend>Legend</legend>
<div>
<div>
<label for="first-name">First Name</label>
<input id="first-name" type="text">
</div>
<div>
<label for="last-name">Last Name</label>
<input id="last-name" type="text">
</div>
<div>
<label for="email">E-Mail</label>
<input id="email" type="email" required>
</div>
<div>
<label for="city">City</label>
<input id="city" type="text">
</div>
<div>
<label for="state">State</label>
<select id="state" class="pure-input-1-2">
<option>AL</option>
<option>CA</option>
<option>IL</option>
</select>
</div>
</div>
<label for="terms" class="pure-checkbox">
<input id="terms" type="checkbox"> I've read the terms and conditions
</label>
<button type="submit" class="pure-button pure-button-primary">Submit</button>
</fieldset>
you can use the code the for you desired result
<form>
<fieldset>
<legend>Legend</legend>
<div class="container">
<div>
<label for="first-name">First Name</label>
<input id="first-name" type="text">
</div>
<div>
<label for="last-name">Last Name</label>
<input id="last-name" type="text">
</div>
<div>
<label for="email">E-Mail</label>
<input id="email" type="email" required>
</div>
<div>
<label for="city">City</label>
<input id="city" type="text">
</div>
<div>
<label for="state">State</label>
<select id="state" class="pure-input-1-2">
<option>AL</option>
<option>CA</option>
<option>IL</option>
</select>
</div>
<div class="clear">
<label for="terms" class="pure-checkbox">
<input id="terms" type="checkbox"> I've read the terms and conditions
</label>
<button type="submit" class="pure-button pure-button-primary">Submit</button>
</div>
</div>
</fieldset>
</form>
and use the style
.container {
width:550px;
float:left;
display:block;
}
.container div{ float:left;
position:relative;
display:block;
width:180px;
margin:5px 0px;
}
.container div label{ width:100%;
display:block;
float:left;
color:#666666;
line-height:20px;
}
.clear{ clear:both;}
.pure-button{ color:#FFFFFF;
background:#0066FF;
border:none;
border-radius:2px;
-moz-border-radius:2px;
-webkit-border-radius:2px;
margin:5px 0px;
padding:5px;
cursor:pointer;
}
.pure-button:hover{ background:#0033FF; }
input[type="text"],input[type="email"],select{
border-radius:2px;
-moz-border-radius:2px;
-webkit-border-radius:2px;
border:1px solid #999;
padding:3px;
}
You may use bootstrap's Grid system http://getbootstrap.com/css/#grid-options
see Demo: http://jsbin.com/weyedivi/1/edit
My HTML has a class called .required that is assigned to required fields.
Here is the HTML:
<form action="/accounts/register/" method="post" role="form" class="form-horizontal">
<input type='hidden' name='csrfmiddlewaretoken' value='brGfMU16YyyG2QEcpLqhb3Zh8AvkYkJt' />
<div class="form-group required">
<label class="col-md-2 control-label">Username</label>
<div class="col-md-4">
<input class="form-control" id="id_username" maxlength="30" name="username" placeholder="Username" required="required" title="" type="text" />
</div>
</div>
<div class="form-group required"><label class="col-md-2 control-label">E-mail</label><div class="col-md-4"><input class="form-control" id="id_email" name="email" placeholder="E-mail" required="required" title="" type="email" /></div></div>
<div class="form-group required"><label class="col-md-2 control-label">Password</label><div class="col-md-4"><input class="form-control" id="id_password1" name="password1" placeholder="Password" required="required" title="" type="password" /></div></div>
<div class="form-group required"><label class="col-md-2 control-label">Password (again)</label><div class="col-md-4"><input class="form-control" id="id_password2" name="password2" placeholder="Password (again)" required="required" title="" type="password" /></div></div>
<div class="form-group required"><label class="col-md-2 control-label">first name</label><div class="col-md-4"><input class="form-control" id="id_first_name" maxlength="30" name="first_name" placeholder="first name" required="required" title="" type="text" /></div></div>
<div class="form-group required"><label class="col-md-2 control-label">last name</label><div class="col-md-4"><input class="form-control" id="id_last_name" maxlength="30" name="last_name" placeholder="last name" required="required" title="" type="text" /></div></div>
<div class="form-group required"><label class="col-md-2 control-label"> </label><div class="col-md-4"><div class="checkbox"><label><input class="" id="id_tos" name="tos" required="required" type="checkbox" /> I have read and agree to the Terms of Service</label></div></div></div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">
<span class="glyphicon glyphicon-star"></span> Sign Me Up!
</button>
</div>
</div>
</form>
I added the following to my CSS;
.form-group .required .control-label:after {
content:"*";color:red;
}
Still that does not give a red * around the required fields. What am I missing here? Isn't there a direct way in Bootstrap 3 to introduce * to required fields?
EDIT
The * in terms and conditions does not appear immediately to a checkbox. How to fix this?
Use .form-group.required without the space.
.form-group.required .control-label:after {
content:"*";
color:red;
}
Edit:
For the checkbox you can use the pseudo class :not(). You add the required * after each label unless it is a checkbox
.form-group.required:not(.checkbox) .control-label:after,
.form-group.required .text:after { /* change .text in whatever class of the text after the checkbox has */
content:"*";
color:red;
}
Note: not tested
You should use the .text class or target it otherwise probably, try this html:
<div class="form-group required">
<label class="col-md-2 control-label"> </label>
<div class="col-md-4">
<div class="checkbox">
<label class='text'> <!-- use this class -->
<input class="" id="id_tos" name="tos" required="required" type="checkbox" /> I have read and agree to the Terms of Service
</label>
</div>
</div>
</div>
Ok third edit:
CSS back to what is was
.form-group.required .control-label:after {
content:"*";
color:red;
}
HTML:
<div class="form-group required">
<label class="col-md-2"> </label> <!-- remove class control-label -->
<div class="col-md-4">
<div class="checkbox">
<label class='control-label'> <!-- use this class as the red * will be after control-label -->
<input class="" id="id_tos" name="tos" required="required" type="checkbox" /> I have read and agree to the Terms of Service
</label>
</div>
</div>
</div>
Assuming this is what the HTML looks like
<div class="form-group required">
<label class="col-md-2 control-label">E-mail</label>
<div class="col-md-4"><input class="form-control" id="id_email" name="email" placeholder="E-mail" required="required" title="" type="email" /></div>
</div>
To display an asterisk on the right of the label:
.form-group.required .control-label:after {
color: #d00;
content: "*";
position: absolute;
margin-left: 8px;
top:7px;
}
Or to the left of the label:
.form-group.required .control-label:before{
color: red;
content: "*";
position: absolute;
margin-left: -15px;
}
To make a nice big red asterisks you can add these lines:
font-family: 'Glyphicons Halflings';
font-weight: normal;
font-size: 14px;
Or if you are using Font Awesome add these lines (and change the content line):
font-family: 'FontAwesome';
font-weight: normal;
font-size: 14px;
content: "\f069";
.form-group .required .control-label:after should probably be .form-group.required .control-label:after. The removal of the space between .form-group and .required is the change.
use simple css,
.myform .required:after {
content: " *";
color: red;
font-weight: 100;
}
<form class="myform">
<div class="col-md-12">
<label for="xxx_fname" class="form-label required">First Name</label>
<input type="text" class="form-control" id="xxx_fname" >
</div>
<div class="col-md-12">
<label for="xxx_lname" class="form-label required">Last Name</label>
<input type="text" class="form-control" id="xxx_lname" >
</div>
</form
The other two answers are correct. When you include spaces in your CSS selectors you're targeting child elements so:
.form-group .required {
styles
}
Is targeting an element with the class of "required" that is inside an element with the class of "form-group".
Without the space it's targeting an element that has both classes. 'required' and 'form-group'
This CSS worked for me:
.form-group.required.control-label:before{
color: red;
content: "*";
position: absolute;
margin-left: -10px;
}
and this HTML:
<div class="form-group required control-label">
<label for="emailField">Email</label>
<input type="email" class="form-control" id="emailField" placeholder="Type Your Email Address Here" />
</div>
This works for me:
CSS
.form-group.required.control-label:before{
content: "*";
color: red;
}
OR
.form-group.required.control-label:after{
content: "*";
color: red;
}
Basic HTML
<div class="form-group required control-label">
<input class="form-control" />
</div>
I modified the css, as i am using bootstrap 3.3.6
.form-group.required label:after{
color: #d00;
font-family: 'FontAwesome';
font-weight: normal;
font-size: 10px;
content: "\f069";
top:4px;
position: absolute;
margin-left: 8px;
}
the HTML
<div class="form-group required">
<label for="return_notes"><?= _lang('notes') ?></label>
<textarea class="form-control" name="return_notes" id="return_notes" required="required"></textarea>
</div>