Using a checkbox within an checkbox accordion? - html

I am trying to create a filter for a website, I made an accordion using check boxs, and I would like to put check boxes within it using
<input name="name" value="value" type="checkbox"/>
However the check box itself wont show.
Here is the code:
<div id="container">
<section id="accordion">
<div>
<input type="checkbox" id="check-1" />
<label for="check-1">Continent</label>
<form action="">
Europe<input name="animal" value="Cat" type="checkbox"/>
</form>
</div>
<div>
<input type="checkbox" id="check-2" />
<label for="check-2">Country</label>
<form action="">
UK<input name="animal" value="Cat" type="checkbox"/>
</form>
</div>
<div>
<input type="checkbox" id="check-3" />
<label for="check-3">League / Competition</label>
<form action="">
Premier League<input name="animal" value="Cat" type="checkbox"/>
</form>
</div>
<div>
<input type="checkbox" id="check-4" />
<label for="check-4">Date</label>
<form action="">
march 13th<input name="animal" value="Cat" type="checkbox"/>
</form>
</div>
</section>
and the CSS:
* {
font-family: Arial, sans;
margin: 0;
padding: 0;
}
h1, h2 {
margin: 1em 0 0 0;
text-align:left;
}
h2 {
margin: 0 0 1em 0;
}
#container {
margin: 10px;
width: 20%;
}
#accordion input {
display: none;
}
#accordion label {
background: #eee;
border-radius: .25em;
cursor: pointer;
display: block;
margin-bottom: .125em;
padding: .25em 1em;
z-index: 20;
}
#accordion label:hover {
background: #ccc;
}
#accordion input:checked + label {
background: #ccc;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
color: white;
margin-: 0;
}
#accordion form{
background: #f7f7f7;
height:0px;
overflow:hidden;
z-index:10;
}
#accordion from input{
padding: 1em;
}
#accordion input:form {
}
#accordion input:checked ~ form {
border-bottom-left-radius: .25em;
border-bottom-right-radius: .25em;
height: auto;
margin-bottom: .125em;
}
DEMO here: http://codepen.io/anon/pen/gPdzWK

So you have a line #accordion input { display: none }, this will hide all the inputs you have.
If you only want to display the input in the form and hide the other ones you can do: #accordion > div > input { display: none } which selects the input that is a direct child of div which itself is a direct child of #accordion.

Related

ordered list numbers are not aligned to the list

I have two doubts to be cleared.
my ordered list has numbering of 1 2 3 4 5 6 etc but am not able to bring that aligned with the questions this is going outside the box.
I have a solution button for each questions but I don't know how to place it on the side of the questions.
here i have attached the code and the expected output. if possible kindly complete the code and post.
* {
margin: 0;
padding: 0;
}
body {
font-family: sans-serif;
font-size: 15px;
height: 100%;
width: 100%;
background-color: antiquewhite;
}
input[type="radio"] {
margin-right: 10px;
}
p {
line-height: 30px;
padding: 30px;
}
.play{
position: absolute;
top: 150px;
left: 300px;
padding: 10px;
border-radius: 10px;
font-family: sans-serif;
background-color: darkgreen;
color: #fff;
}
form[name=quiz] {
margin-left: 10%;
margin-right: 10%;
}
ol{
padding: 10px;
list-style-position: inside;
}
ol li{
background-color: #fff;
border-radius: 15px;
margin: 10px;
box-shadow: 0px 1.5px 2px 0px rgb(91, 91, 91);
}
<form name="quiz" id="quiz">
<ol>
<li>
<div class="q1">
<p><strong>The value of \(\frac{1}{{{{\log }_4}120}} + \frac{1}{{{{\log }_5}120}} + \frac{1}{{{{\log }_6}120}}\) is</strong><br><br>
<input type="radio" name="question1" value="0">A.0<br>
<input type="radio" name="question1" value="1">B.1<br>
<input type="radio" name="question1" value="24">C.24<br>
<input type="radio" name="question1" value="120">D.120<br>
</p>
</div>
<div>
<button class="play">Play Solution</button>
</div>
</li>
<li>
<div>
<p><strong>For a 3x3 matrix A, |A| = 4 and adj A = \(\left( {\begin{array}{*{20}{c}}1&p&3\\1&3&3\\2&4&4\end{array}} \right)\), then the value of p is</strong><br><br>
<input type="radio" name="question2" value="4">A.4<br>
<input type="radio" name="question2" value="11">B.11<br>
<input type="radio" name="question2" value="5">C.5<br>
<input type="radio" name="question2" value="0">D.0<br>
</p>
</div>
</li>
Your question isn't aligning with the number of your ordered list because you're using a <p> element for it which is set to display: block; by default. Removing the <p> element will fix the problem.
You can use a <table> to structure your answers and the solution buttons.
* {
margin: 0;
padding: 0;
}
body {
font-family: sans-serif;
font-size: 15px;
height: 100%;
width: 100%;
background-color: antiquewhite;
}
form[name=quiz] {
margin-left: 10%;
margin-right: 10%;
}
ol {
padding: 10px;
list-style-position: inside;
}
ol li {
background-color: #fff;
border-radius: 15px;
margin: 10px;
padding: 30px;
box-shadow: 0px 1.5px 2px 0px rgb(91, 91, 91);
}
li table {
width: 100%;
}
li table td {
vertical-align: top;
padding-top: 20px;
}
li table td:first-child {
width: 70%;
}
td p {
padding-bottom: 10px;
}
td button {
width: 100%;
padding: 10px;
margin-bottom: 5px;
border-radius: 10px;
background-color: darkgreen;
color: #fff;
}
<form name="quiz" id="quiz">
<ol>
<li class="q1">
<strong>The value of \(\frac{1}{{{{\log }_4}120}} + \frac{1}{{{{\log }_5}120}} + \frac{1}{{{{\log }_6}120}}\) is</strong>
<table>
<tr>
<td>
<p>
<input type="radio" name="question1" id="question1" value="0">
<label for="question1">A. 0</label>
</p>
<p>
<input type="radio" name="question1" id="question2" value="1">
<label for="question2">B. 1</label>
</p>
<p>
<input type="radio" name="question1" id="question3" value="24">
<label for="question3">C. 24</label>
</p>
<p>
<input type="radio" name="question1" id="question4" value="120">
<label for="question4">D. 120</label>
</p>
</td>
<td>
<button class="play">Play Solution</button>
<button class="play">Text Solution</button>
</td>
</tr>
</table>
</li>
</ol>
</form>

picture behind signUp form

I am doing a vue project,but I want to create a form to log in and put an image behind the form.
I tried, but when I put the image behind the form, it did not appear on the page.
What should I do to add a picture behind the form?
Html:Here in this section I wrote HTML code.
<template>
<div>
<div class="signup-form">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
<title>Bootstrap Simple Login Form with Blue Background</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<form action="/examples/actions/confirmation.php" method="post">
<h2>Sign Up</h2>
<p>Please fill in this form to create an account!</p>
<hr>
<div class="form-group">
<div class="row">
<div class="col-xs-6"><input type="text" class="form-control" name="first_name"
placeholder="First Name" required="required"></div>
<div class="col-xs-6"><input type="text" class="form-control" name="last_name"
placeholder="Last Name" required="required"></div>
</div>
</div>
<div class="form-group">
<input type="email" class="form-control" name="email" placeholder="Email"
required="required">
</div>
<div class="form-group">
<input type="password" class="form-control" name="password" placeholder="Password" `
required="required">`
</div>
<div class="form-group">
<input type="password" class="form-control" name="confirm_password" placeholder="Confirm
Password" required="required">
</div>
<div class="form-group">
<label class="checkbox-inline"><input type="checkbox" required="required"> I accept the
Terms of Use & Privacy Policy</label>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-lg">Sign Up</button>
</div>
</form>
<div class="hint-text">Already have an account? Login here</div>
</div> </div>
</template>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
export default {
data: {
counter: 0
}
};
</script>
Css:Here in this section i wrote Css Code.
<style scoped>
body {
color: #fff;
background: #3598dc;
font-family: 'Roboto', sans-serif;
}
.form-control{
height: 41px;
background: #f2f2f2;
box-shadow: none !important;
border: none;
}
.form-control:focus{
background: #e2e2e2;
}
.form-control, .btn{
border-radius: 3px;
}
.signup-form{
width: 390px;
margin: 30px auto;
}
.signup-form form{
color: #999;
border-radius: 3px;
margin-bottom: 15px;
background: #fff;
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
padding: 30px;
}
.signup-form h2 {
color: #333;
font-weight: bold;
margin-top: 0;
}
.signup-form hr {
margin: 0 -30px 20px;
}
.signup-form .form-group{
margin-bottom: 20px;
}
.signup-form input[type="checkbox"]{
margin-top: 3px;
}
.signup-form .row div:first-child{
padding-right: 10px;
}
.signup-form .row div:last-child{
padding-left: 10px;
}
.signup-form .btn{
font-size: 16px;
font-weight: bold;
background: #3598dc;
border: none;
min-width: 140px;
}
.signup-form .btn:hover, .signup-form .btn:focus{
background: #2389cd !important;
outline: none;
}
.signup-form a{
color: #fff;
text-decoration: underline;
}
.signup-form a:hover{
text-decoration: none;
}
.signup-form form a{
color: #3598dc;
text-decoration: none;
}
.signup-form form a:hover{
text-decoration: underline;
}
.signup-form .hint-text {
padding-bottom: 15px;
text-align: center;
}</style>
You can use CSS' position property to stack an element on top of another. Here is an example.
/** GENERAL STYLES **/
* {
box-sizing: border-box;
}
form {
width: 300px;
margin: 1em auto;
border: 1px solid #eee;
}
form .form-group label,
form .form-group input {
width: 100%;
}
form h2 {
margin: 0 0 1em;
}
/** THE FIXES **/
.relative {
position: relative;
}
form .form-content {
padding: 1em;
position: relative;
}
form .behind-form {
position: absolute;
bottom: 0;
width: 100%;
}
form .behind-form img {
width: 100%;
display: block;
}
<form class="relative">
<div class="behind-form">
<img src="https://pixabay.com/get/52e8d3454e56a914f1dc8460da29317e173edce7545972_640.jpg" />
</div>
<div class="form-content">
<h2>Sign Up</h2>
<p>Please fill in this form to create an account!</p>
<div class="form-group">
<label>Name</label>
<input type="text" />
</div>
<div class="form-group">
<label>Email</label>
<input type="text" />
</div>
</div>
</form>

input file label and check-boxes same width

I need the upload label and the check-boxes to be at the same width.
I tried to fix it with jquery but didn't work, also flex-grow: 1; and flex: 1 1 0; that in How to make flexbox items the same size? didn't work.
It worked on jquery resize function but, the form container gets extra width.
here is the jsfiddle
fieldset {
border: 2px solid #0062b5;
border-radius: 5px;
padding: 15px;
margin-bottom: 20px;
}
input[type=checkbox], input[type=file] {
display: none;
}
.Center {
display: flex;
flex-wrap: nowrap;
}
.RadioLabel {
cursor: pointer;
flex: 1;
border-radius: 5px;
padding: 10px;
}
.Center input[type=file] + label {
flex: 1;
}
.MiddelLabel {
margin: 0 5px;
}
input[type=file] + label {
cursor: not-allowed;
transition: 0.3s;
line-height: 50px;
padding: 0 10px;
background-color: #ebebe4;
}
input[type=checkbox]:checked + label {
background-color: #d1e9ff;
}
label img {
padding-right: 15px;
vertical-align: middle;
margin-top: -2px;
}
#LinkFile {
flex: 1 1 0px;
font-size: 16px;
margin: 0;
}
legend {
padding: 0 5px;
color: #0059a3;
font-weight: bold;
}
<fieldset>
<legend>Template (optional)</legend>
<div class="Center">
<input type="checkbox" name="Layout" id="Template" checked/><label id="Mid" for="Template" class="RadioLabel">Template</label>
<input type="checkbox" name="Layout" id="Image" checked/><label for="Image" class="RadioLabel MiddelLabel">Image</label>
<input type="checkbox" name="Layout" id="Link" checked/><label for="Link" class="RadioLabel">Link</label>
</div><br/>
<div class="Center">
<input type="file" name="TemplateFile" id="TempFile" class="inputfile" disabled/>
<label for="TempFile" class="FileLabel UpWidth"><img src="https://pngimage.net/wp-content/uploads/2018/06/icon-upload-png-6.png" width="20">Upload Template</label>
<input type="file" name="ImageFile" id="ImgFile" class="inputfile" disabled/>
<label for="ImgFile" class="FileLabel MiddelLabel UpWidth"><img src="https://pngimage.net/wp-content/uploads/2018/06/icon-upload-png-6.png" width="20">Upload Image</label>
<input type="text" name="LinkFile" id="LinkFile" class="UpWidth" placeholder="Template Link" disabled/>
</div>
</fieldset>
Thank you.
You should look into the display: grid; feature of CSS. There's no way to ensure two separate flex containers will have the elements be the same width, unless you set it yourself (which defeats the purpose of flex).
Just set grid-template-columns: 1fr 1fr 1fr; to get 3 columns of the same width, and keep your elements in one container.
fieldset {
border: 2px solid #0062b5;
border-radius: 5px;
padding: 15px;
margin-bottom: 20px;
}
input[type=checkbox], input[type=file] {
display: none;
}
.Center {
display: grid;
grid-gap: 5px;
grid-template-columns: 1fr 1fr 1fr;
}
.RadioLabel {
cursor: pointer;
flex: 1;
border-radius: 5px;
padding: 10px;
}
.MiddelLabel {
margin: 0 5px;
}
input[type=file] + label {
cursor: not-allowed;
transition: 0.3s;
line-height: 50px;
padding: 0 10px;
background-color: #ebebe4;
}
input[type=checkbox]:checked + label {
background-color: #d1e9ff;
}
label img {
padding-right: 15px;
vertical-align: middle;
margin-top: -2px;
}
#LinkFile {
flex: 1 1 0px;
font-size: 16px;
margin: 0;
}
legend {
padding: 0 5px;
color: #0059a3;
font-weight: bold;
}
<fieldset>
<legend>Template (optional)</legend>
<div class="Center">
<input type="checkbox" name="Layout" id="Template" checked/><label id="Mid" for="Template" class="RadioLabel">Template</label>
<input type="checkbox" name="Layout" id="Image" checked/><label for="Image" class="RadioLabel MiddelLabel">Image</label>
<input type="checkbox" name="Layout" id="Link" checked/><label for="Link" class="RadioLabel">Link</label>
<input type="file" name="TemplateFile" id="TempFile" class="inputfile" disabled/>
<label for="TempFile" class="FileLabel UpWidth"><img src="https://pngimage.net/wp-content/uploads/2018/06/icon-upload-png-6.png" width="20">Upload Template</label>
<input type="file" name="ImageFile" id="ImgFile" class="inputfile" disabled/>
<label for="ImgFile" class="FileLabel MiddelLabel UpWidth"><img src="https://pngimage.net/wp-content/uploads/2018/06/icon-upload-png-6.png" width="20">Upload Image</label>
<input type="text" name="LinkFile" id="LinkFile" class="UpWidth" placeholder="Template Link" disabled/>
</div>
</fieldset>

How to make the textarea label display correctly [duplicate]

This question already has answers here:
What methods of ‘clearfix’ can I use?
(29 answers)
HTML radio buttons allowing multiple selections
(6 answers)
Closed 4 years ago.
I created a responsive form which changes to two columns when the screen size is resized. It mostly works the way I want it to.
However the label for textarea keeps showing incorrectly. I want it to display on a new line, but it keeps showing in the area of radio buttons.
There is also an issue with radio buttons where both can be selected at the same time. I have been trying to figure out what I did wrong but I can't find a solution.
Here is my code on jsfiddle.
/* CSS */
.myForm {
padding: 40px 20px;
}
.myForm h2,
.myForm p {
text-align: center;
padding: 0 10px;
}
.myForm h2 {
margin-bottom: 20px;
font-size: 20px;
font-weight: bold;
font-family: sans-serif;
}
.myForm p {
margin-bottom: 20px;
font-size: 12px;
}
.myForm label {
font-size: 14px;
}
form input {
border: 1px solid #a9a9a9;
border-radius: 3px;
height: 25px;
width: 96%;
margin: 10px 0;
font-size: 14px;
padding: 5px;
}
.label,
.radio input[type="radio"] {
display: inline;
float: left;
width: auto;
margin: 10px 0;
padding: 0 10px;
}
input[type="radio"],
input.radio {
vertical-align: text-top;
width: 13px;
height: 13px;
padding: 0;
margin: 0;
position: relative;
overflow: hidden;
top: -8px;
right: 5px;
}
.msg textarea {
width: 96%;
border: 1px solid #a9a9a9;
border-radius: 3px;
margin: 10px 0;
font-size: 14px;
padding: 5px;
}
form button {
background-color: #a9a9a9;
color: #fff;
width: 100%;
text-transform: uppercase;
padding: 10px;
border: none;
border-radius: 3px;
}
#media only screen and (min-width: 768px) {
/*Left form column*/
.left {
display: block;
float: left;
width: 48%;
}
/*Right form column*/
.right {
display: block;
float: right;
width: 48%;
}
.label,
.radio input[type="radio"] {
padding-right: 30px;
padding-left: 30px;
}
}
<!-- HTML -->
<form class="myForm">
<h2>Lorem ipsum</h2>
<p>text</p>
<div class="fields">
<label class="left">First Name
<input type="text" name="other"></label>
<label class="right">Last Name
<input type="text" name="other"></label>
<label class="left">text
<input type="text" name="other"></label>
<label class="right">text
<input type="text" name="other"></label>
<label class="left">text
<input type="text" name="other"></label>
<label class="right">text
<input type="text" name="other"></label>
<label class="left">text
<input type="text" name="other"></label>
<div class="radio right">
<label>Some text</label><br>
<label class="label">
<input type="radio" name="phone" value="phone">Phone</label>
<label class="label close">
<input type="radio" name="email" value="email">Email</label>
</div>
<div class="msg">
<label>Message</label>
<textarea rows="5"></textarea>
</div>
</div>
<button type="button" name="button">Send</button>
</form>
this should help:
.msg{
clear:both;
}
To fix the two problems you describe:
Your radio buttons need to have the same name field to be in the same group. If you set name="contact" for both, then they'll no longer be selectable at the same time.
You should remove float: left; from your CSS rules for .radio input[type="radio"]. This is taking precedence over the display: block; of the .msg div and causing them to be displayed on the same line.

Unwanted white space in html to the right of search bar

I am trying to make a search bar, with an anchor containing an icon. I'm trying to directly connect the two (button fixed to the right of searchbar) but there is white space not wanting to leave.
.search input [type="search"] {
margin-right: 0;
white-space: nowrap;
}
.search a {
padding: 5px;
border-top-right-radius: 7px;
border-bottom-right-radius: 7px;
margin-left: 0;
}
.search i {
padding: 5px;
}
<div class="search">
<form action="" method="post">
<b>Search by</b>
<input type="checkbox" value="">Male</input>
<input type="checkbox" value="">Female</input>
<input type="search" placeholder="Searchtext">
<i>placeholder</i>
</form>
</div>
The duplicate does apply to your question as inputs are inline-block.
One thing to consider is that your "search" and "button" could be considered a single element. You could group them as such and then apply a float to the elements.
.searchBox {
/*Floats will be relative to this*/
position: relative;
display: inline-block;
}
.searchBox input {
/*Float the input*/
float: left;
}
.search input[type="search"] {
margin-right: 0;
white-space: nowrap;
}
.search a {
padding: 5px;
border-top-right-radius: 7px;
border-bottom-right-radius: 7px;
margin-left: 0;
/*Purely to demonstrate*/
border: solid 1px black;
}
.search i {
padding: 5px;
}
<div class="search">
<form action="" method="post">
<b>Search by</b>
<input type="checkbox" value="" />Male
<input type="checkbox" value="" />Female
<div class="searchBox">
<input type="search" placeholder="Searchtext">
<i>placeholder</i>
</div>
</form>
</div>
You also have a couple of other issues with your code:
input is self closing and shouldn't have a closing tag, note Permitted Content in the docs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
You have an unwanted space between input and [type="search"]. This would attempt to match an element with an attribute of search that is a descendant of an input element.
I have addressed these in my code.
I think below code might serve your purpose.
.blockTitle{
padding-right:1em;
font-weight:bold;
}
.search{
display:block;
width:auto;
}
.search form{
display:block;
width:100%;
margin:0;
padding:0;
}
.checkbox + label{
display:inline-block;
padding:0 0.25em;
line-height:1.4em;
}
.searchBoxContainer{
display:block;
width:80%;
position:relative;
padding:0.2em;
}
.searchBoxContainer input[type="search"]{
width:100%;
display:block;
position:relative;
z-index:0;
padding:0 2.5em 0 0;
line-height:inherit;
margin:0;
}
.searchCustomBtn{
position:absolute;
top:0.75em;
right:-2em;
z-index:1;
line-height: 1.5em;
}
<div class="search">
<form action="" method="post">
<span class="blockTitle">Search by</span>
<input type="checkbox" value="" class="checkbox" id="maleChkBx" /><label for="maleChkBx">Male</label>
<input type="checkbox" value="" class="checkbox" id="femaleChkBx" /><label for="femaleChkBx">Female</label>
<div class="searchBoxContainer">
<input type="search" id="searchBox" placeholder="Searchtext">
Search-Icon
</div>
</form>
</div>