how to target a checkbox inside a div inside a div table - html

im trying to add the input/label inside a toggle/div to hide the list of input but cant seem to target it without the checkbox not working. i tried adding the div#cars:checked ~ .container .cars{} but still not working.all i want is to wrap the input in a table example
<div class="parkingDivTable" style="border:solid 2px black;">
<table>
<input type="checkbox" id="all" checked> Show all<br>
<input type="checkbox" id="cars"> Cars<br>
<input type="checkbox" id="animals"> Animals<br>
<input type="checkbox" id="fruits"> Fruits<br>
<input type="checkbox" id="color" > Colors<br>
</table>
</div>
something like this but the input only works outside the div any suggestions
#all:checked ~ .container .filterDiv{
display: block;
border:red solid 2px;
}
.filterDiv, :not(#all):checked ~ .container .filterDiv{
float: left;
background-color: #2196F3;
color: #ffffff;
width: 100px;
line-height: 100px;
text-align: center;
margin: 2px;
display: none;
border:solid 2px blue;
}
#animals:checked ~ .container .animals,
#fruits:checked ~ .container .fruits,
#color:checked ~ .container .colors{
display: block;
}
#cars:checked ~ .container .cars
{
display: block;
border:green solid 2px;
}
.container {
margin-top: 20px;
overflow: hidden;
}
<h2>Filter DIV Elements</h2>
<input type="checkbox" id="all" checked> Show all<br>
<input type="checkbox" id="cars"> Cars<br>
<input type="checkbox" id="animals"> Animals<br>
<input type="checkbox" id="fruits" > Fruits<br>
<input type="checkbox" id="color" > Colors<br>
<div class="container">
<div class="filterDiv cars">BMW</div>
<div class="filterDiv colors fruits">Orange</div>
<div class="filterDiv cars">Volvo</div>
<div class="filterDiv colors">Red</div>
<div class="filterDiv cars animals">Mustang</div>
<div class="filterDiv colors">Blue</div>
<div class="filterDiv animals">Cat</div>
<div class="filterDiv animals">Dog</div>
<div class="filterDiv fruits">Melon</div>
<div class="filterDiv fruits animals">Kiwi</div>
<div class="filterDiv fruits">Banana</div>
<div class="filterDiv fruits">Lemon</div>
<div class="filterDiv animals">Cow</div>
</div>

Related

label and the felder are not center in the rows

I have a problem with your form, how can I put the text and the elements at the same distance, e.g. show the label next to the fields, they are not on the same line, i.e. not centered on the line,
pls see pic on the Link
My Form
I have a problem with your form, how can I put the text and the elements at the same distance, e.g. show the label next to the fields, they are not on the same line, i.e. not centered on the line,
pls see pic on the Link
My Form
I have a problem with your form, how can I put the text and the elements at the same distance, e.g. show the label next to the fields, they are not on the same line, i.e. not centered on the line,
pls see pic on the Link
My Form
body{
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
background-color: #FFBB00;
}
.container{
width: 40%;
margin: 4% auto;
padding: 50px;
background-color: #fff;
border-radius: 15px;
box-shadow: #ccc 0 0 10px 0; /* للظل لحتى يطلع متناسب */
}
.title h1{
position: relative;
text-align: center;
font-size: 28px;
text-transform: uppercase;
}
.title h1::after{
content: "";
width: 30%;
height: 3px;
background-color: #FFBB00;
position: absolute;
top: 110%;
left: 35%;
}
.inputFeld{
padding: 10px;
margin: 10px;
border-radius:4px;
border: 1px solid #ccc;
}
.inputFeld:focus{
background-color: #FFBB00; ;
}
/* */
.parent-line{
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: center;
padding: 15px;
}
.parent-line .line-link{
display: flex;
flex: 1;
}
.parent-line .line-right{
flex: 1;
display: flex;
}
.parent-one-line{
padding: 15px;
}
.container .line label{
display: inline-block;
width: 150px;
text-align: left;
}
/* */
.btn{
padding: 19px 10px;
margin-bottom: 500px;
background-color: #000;
color: #fff;
border: none;
float: right;
cursor: pointer;
width: 100%;
}
.btn:hover{
background-color: #FFBB00;
color: #000;
}
.checken{
padding: 10px;
}
.select{
padding: 10px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<link rel="stylesheet" href="style.css">
<style>
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#300&display=swap');
</style>
<body>
<section class="container">
<dic class="title"><h1>ITEMS VERLINKEN </h1></dic>
<form action="">
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line"> <label class="" for=""> Link URL </label> <input class="inputFeld" type="text" name="" id="" > </div>
</div>
<div class="line-right">
<div class="line"> <label for=""> +articleNum+ </label> <input class="inputFeld" type="text" name="" id="" > </div>
</div>
</div>
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line"> <label for=""> Full PDF name </label> <input class="inputFeld" type="text" name="" id="" placeholder="Example: test.pdf ">
</div>
</div>
<div class="line-right">
<div class="line"> <label for=""> Full PDF Links </label>
<input class="checkbox" type="checkbox" name="" id="">
</div>
</div>
</div>
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line"> <label for=""> PDF Width in mm</label>
<input class="inputFeld" type="text" name="" id="" placeholder="Example: 212" size="4">
</div>
</div>
<div class="line-right">
<div class="line"> <label for=""> PDF Height in mm</label>
<input class="inputFeld" type="text" name="" id="" placeholder="Example: 290 " size="4">
</div>
</div>
</div>
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line">
<label for=""> Border around links</label>
<select class="select" name="" id="">
<option value="">No</option>
<option value="">Yes</option>
</select>
</div>
</div>
<div class="line-right">
<div class="line"> <label for=""> Border(RGB):</label>
<input class="inputFeld" type="text" name="" id="" placeholder="R" size="1">
<input class="inputFeld" type="text" name="" id="" placeholder="G" size="1" >
<input class="inputFeld" type="text" name="" id="" placeholder="B" size="1">
</div>
</div>
</div>
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line">
<label for=""> Border Width(mm)</label> <select class="select" name="" id="">
<option value="">0</option>
</select>
</div>
</div>
<div class="line-right">
<div class="line">
<label for="">Margin top (mm)</label> <select class="select" name="" id="">
<option value="">0</option>
</select>
</div>
</div>
</div>
<!-- -->
<div class="parent-one-line">
<div class="line"> <label for=""> Save settings: </label> <input class="inputFeld" type="text" name="" id="" placeholder="Example: Customer1 ">
<h5>Leave empty to prevent saving.</h5>
</div>
<input class="btn" type="button" value="Start">
</div>
</form>
</section>
</body>
</html>
Simply add align-items:center to
.parent-line .line-right{
flex: 1;
display: flex;
}
and increase/decrease input text height/font size to match the center.

how can I align the labels & inputs to the right

how can I align the labels & inputs to the right
like that all of then appear in the same line
.radioContainer{
width: fit-content;
margin: 5px;
margin-top: 20px;
background-color: aqua;
padding-bottom: 25px;
}
<div class="radioContainer" style="margin-bottom: 40px; margin-right: 0px; ">
<label class="title" for="">fav food</label>
<label for="burger">burger</label>
<input type="checkbox" id="burger">
<br>
<label for="fries">fries</label>
<input type="checkbox" id="fries">
<br>
<label for="onionRings">onion rings</label>
<input type="checkbox" id="onionRings">
<br>
<label for="cackes">cakes</label>
<input type="checkbox" id="cackes" >
<small></small>
</div>
To have them in the same line, I would start by removing <br /> from your code. Then set the css for input and label to be inline-block, something like:
.radioContainer{
width: fit-content;
margin: 5px;
margin-top: 20px;
background-color: aqua;
padding-bottom: 25px;
}
label, input { display: inline-block; }
<div class="radioContainer" style="margin-bottom: 40px; margin-right: 0px; ">
<label class="title" for="">fav food</label>
<label for="burger">burger</label>
<input type="checkbox" id="burger">
<label for="fries">fries</label>
<input type="checkbox" id="fries">
<label for="onionRings">onion rings</label>
<input type="checkbox" id="onionRings">
<label for="cackes">cakes</label>
<input type="checkbox" id="cackes" >
<small></small>
</div>
To make all inputs inline, just remove all the <br /> tags.
Example:
<div class="radioContainer" style="margin-bottom: 40px; margin-right: 0px; ">
<label class="title" for="">fav food</label>
<label for="burger">burger</label>
<input type="checkbox" id="burger">
<label for="fries">fries</label>
<input type="checkbox" id="fries">
<label for="onionRings">onion rings</label>
<input type="checkbox" id="onionRings">
<label for="cackes">cakes</label>
<input type="checkbox" id="cackes">
<small></small>
</div>
Codepen: https://codepen.io/manaskhandelwal1/pen/jOMeqex
I understood your Question that you want them still below each other but aligned to the right side. So i made a solution using flexbox instead of the hard breaks. I commented the Code where i made changes and why, html and css.
Basically i used a colum and put each item-combination (label and checkbox)in a new row-div.
.radioContainer{
width: fit-content;
margin: 5px;
margin-top: 20px;
background-color: aqua;
padding-bottom: 25px;
/*make item a flexbox-container*/
display: flex;
/*combination of flex-direction and flex-wrap*/
flex-flow: column wrap;
}
.row{
/*make item a flexboc container*/
display: flex;
/*flex-flow: row nowrap; this is the default value of flex, which is why you dont need it,
just wanted to leave it in as a comment so you know whats happening*/
/*Align the contents on the end of each row*/
justify-content: flex-end;
}
<div class="radioContainer" style="margin-bottom: 40px; margin-right: 0px; ">
<!--removed the hard breaks and added row-divs around each item combination-->
<div class="row">
<label class="title" for="">fav food</label>
</div>
<div class="row">
<label for="burger">burger</label>
<input type="checkbox" id="burger">
</div>
<div class="row">
<label for="fries">fries</label>
<input type="checkbox" id="fries">
</div>
<div class="row">
<label for="onionRings">onion rings</label>
<input type="checkbox" id="onionRings">
</div>
<div class="row">
<label for="cackes">cakes</label>
<input type="checkbox" id="cackes" >
</div>
<small></small>
</div>

css: how to display a radiobuttonlist horizontally?

How can I align a radiobuttonlist horizontally? This one is to capture a gender value , male/female. I want to keep the name input css the same. This is the html:
<label for="temp">Gender</label>
<label for="one">Male</label>
<input type="radio" id="one" name="first_item" value="1" />
<label for="two">Female</label>
<input type="radio" id="one" name="first_item" value="2" />
The css:
.grid-container {
display: grid;
grid-column-gap: 5px;
grid-template-columns: auto auto;
background-color: #2196f3;
padding: 10px;
}
.left-griditem {
}
input,
label {
display: block;
}
Here is a codepen. Currently the buttons are in a vertical position.
If you want only the radio buttons, add this style:
#genderArea input, #genderArea label{
display: inline;
}
and use this HTML:
<div class="grid-container">
<div class="left-griditem">
<label for="name">Name</label>
<input id="name" type="text" name="name">
<label for="temp">Gender</label>
<span id="genderArea">
<label for="one">Male</label>
<input type="radio" id="one" name="first_item" value="1" />
<br>
<label for="two">Female</label>
<input type="radio" id="one" name="first_item" value="2" />
</span>
</div>
<div class="right-griditem">2</div>
</div>
You have to wrap particular row which you want to make under a div/ a tag.
.grid-container {
display: grid;
grid-column-gap: 5px;
grid-template-columns: auto auto;
background-color: #2196f3;
padding: 10px;
}
.left-griditem {}
input,
label {
display: inline-block;
}
div.item>label:first-child {
width: 70px;
font-weight: bold;
}
div.item:first-child>input,
div.item:first-child>label {
display: block
}
body {
background: hsl(221, 64%, 24%);
color: hsl(235, 9%, 39%);
font-family: "Open Sans", sans-serif;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
margin: 2rem 1rem 1rem 1rem;
}
div {
background: #fff;
padding: 1vw 2vw;
}
<div class="grid-container">
<div class="left-griditem">
<div class="item">
<label for="name">Name</label>
<input id="name" type="text" name="name">
</div>
<div class="item">
<label for="temp">Gender</label>
<label for="one">Male</label>
<input type="radio" id="one" name="first_item" value="1" />
<label for="two">Female</label>
<input type="radio" id="two" name="first_item" value="2" />
</div>
</div>
<div class="right-griditem">2</div>
</div>
Try this simple code using table, tr and td tags
<table>
<tr>
<td>
<label for="one">Male</label>
</td>
<td>
<input type="radio" id="one" name="first_item" value="1" />
</td>
<td style="widht:20px;"></td>
<td>
<label for="two">Female</label>
</td>
<td>
<input type="radio" id="one" name="first_item" value="2" />
</td>
</tr>
</table>
This approach gives you the flexibility to put controls, the way you want
Change this:
input,
label {
display: block;
}
To this:
input,
label {
display: inline;
}

My <section> is in the top of my <nav>, as far as I know <nav> is in top of <section>

SO my <section> appears in te top of the <nav>, let say it will text wrap the <nav> section. How will I put the <section> below the <nav>
It gives me problem every time i put some text in and the text will appear behind the nav
body {
background-color: white;
}
table {
border-collapse: collapse;
width: 100%;
}
td,
th {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
header,
footer {
padding: 1em;
color: white;
background-color: grey;
clear: left;
text-align: center;
}
nav ul {
list-style-type: none;
padding: 0;
}
nav ul a {
text-decoration: none;
}
section {}
aside {
float: left;
}
aside.right {
float: right;
}
<header>
<img src="mf.png" alt="Mandaue Foam" align="left" style="width:180px;height:108.56px;">
<div style="text-align: right;">Search: <input type="text" name="Search" placeholder="Search Here"></br>
</br>
</br>
</br>
</div>
<div style="text-align: right;">AF No. : <input type="text" name="AF No." placeholder="AF No."></br>
</div>
<div style="text-align: right;">Asset No. : <input type="text" name="AF No." placeholder="Asset No."></div>
<div style="text-align: center; text"><strong> ACCOUNTABILITY FORM <strong></div>
</br>
</header>
<nav>
<div style='position:fixed;top:230px;left:100px;'><input type="radio" name="progress" id="progress1" value="1" tabIndex="1" onClick="ckChange(this)"> For Official Use </br></br>
<input type="radio" name="progress" id="progress2" value="1" tabIndex="1" onClick="ckChange(this)"> For use in showroom to be returned on <input type ="date"></br></br>
<input type="radio" name="progress" id="progress3" value="1" tabIndex="1" onClick="ckChange(this)"> For use in showroom not to be returned
<div style='position:fixed;top:230px;right:150px;'><input type="radio" name="progress" id="progress4" value="1" tabIndex="1" onClick="ckChange(this)"> For sample</br></br><div>
<input type="radio" name="progress" id="progress5" value="1" tabIndex="1" onClick="ckChange(this)"> On Loan </br></br>
<input type="radio" name="progress" id="progress6" value="1" tabIndex="1" onClick="ckChange(this)"> Other <input type="text" name="progress" id="progress6" placeholder="State the Purpose">
</nav>
<section>
</section>
Your html code is invalid. please check again, and that's what causes your above .
please look at jsfiddle for the full code.
https://jsfiddle.net/vLbmc6z9/
<header>
<div>
<img src="mf.png" alt="Mandaue Foam" align="left">
</div>
</header>

How do I get these text input boxes to line up?

How do I get the text input boxes to line up?
The password input box is slightly to the left, it is not aligned with the username text input box.
I am using Java, in Eclipse.
<div>
<div id="header">
<h1>Login</h1>
</div>
<form name="loginform">
<fieldset>
<legend>Login Form</legend>
<label>Username:
<input type="text" name="username" /><span>*</span>
</label>
<label>Password:
<input type="password" name="pass" /><span>*</span>
</label>
<input type="reset" class="resetButton" />
<input type="submit" value="Login" class="submitButton" />
</fieldset>
</form>
</div>
If you want it to be dynamic, you need a grid (row/column) structure, and the best one (cross browser) today is display: table, as display: grid is still widely unsupported (working draft | caniuse)
h1 {letter-spacing: 1px; font-size: .4in; color: green;}
legend {font-variant: small-caps; font-weight: bold}
fieldset{width: 300px; font-family: Arial, sans-serif;
background-color : limegreen}
label {display: block; position: relative; line-height: 2;}
.text {position: absolute; margin-left: 20px; width: 15em; left: 80px}
.grid {
display: table;
}
.row {
display: table-row;
}
.col {
display: table-cell;
padding: 6px 0 0 6px;
}
.col.after:after {
content: ' *';
color: red;
}
<div>
<div id="header">
<h1>Login</h1>
</div>
<form name="loginform">
<fieldset>
<legend>Login Form</legend>
<div class="grid">
<div class="row">
<div class="col">
<label for="username">Username:</label>
</div>
<div class="col after">
<input type="text" name="username" id="username"/>
</div>
</div>
<div class="row">
<div class="col">
<label for="pass">Password:</label>
</div>
<div class="col after">
<input type="password" name="pass" id="pass"/>
</div>
</div>
<div class="row">
<div class="col">
</div>
<div class="col">
<input type="reset" class ="resetButton"/>
<input type="submit" value = "Login" class="submitButton"/>
</div>
</div>
</div>
</fieldset>
</form>
</div>
In a perfect W3 standard world, your label would be a field that stands on its own, not a field that encapsulates the input. So, for instance:
<label for="username">Username:</label>
<input id="username" type="text" name="username"/><span>*</span>
The "for" tag refers to the ID of the input field that you'd have to add. Styling, then would be as simple as adding on a width to the style of the label. For positioning purposes, you could display-inline on the required asterisk to position it after the input.
Enclose the username and password labels in an inline-block span and give that span a width.
Your updated html looks like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1"/>
<title>Test</title>
</head>
<body>
<style tpye ="text/css">
h1 {letter-spacing: 1px; font-size: .4in; color: green;}
span {color: red}
legend {font-variant: small-caps; font-weight: bold}
fieldset{width: 300px; font-family: Arial; sans-serif;
background-color : limegreen}
label {display: block; position relative; line-height: 2;
margin: 10px 0px;}
.text {position: absolute; margin-left: 20px; width: 15em; left: 80px}
span.myspan{width: 100px; display:inline-block;}
</style>
<div>
<div id="header">
<h1>Login</h1>
</div>
<form name="loginform">
<fieldset>
<legend>Login Form</legend>
<label><span class="myspan">Username:</span> <input type="text" name="username"/><span>*</span></label>
<label><span class="myspan">Password:</span> <input type="password" name="pass"/><span>*</span></label>
<input type="reset" class ="resetButton"/>
<input type="submit" value = "Login" class="submitButton"/>
</fieldset>
</form>
</div>
</body>
</html>
Test here: https://jsfiddle.net/nabtron/d4cr66oa/
This one worked, thank you.
h1 {letter-spacing: 1px; font-size: .4in; color: green;}
legend {font-variant: small-caps; font-weight: bold}
fieldset{width: 300px; font-family: Arial, sans-serif;
background-color : limegreen}
label {display: block; position: relative; line-height: 2;}
.text {position: absolute; margin-left: 20px; width: 15em; left: 80px}
.grid {
display: table;
}
.row {
display: table-row;
}
.col {
display: table-cell;
padding: 6px 0 0 6px;
}
.col.after:after {
content: ' *';
color: red;
}
<div>
<div id="header">
<h1>Login</h1>
</div>
<form name="loginform">
<fieldset>
<legend>Login Form</legend>
<div class="grid">
<div class="row">
<div class="col">
<label for="username">Username:</label>
</div>
<div class="col after">
<input type="text" name="username" id="username"/>
</div>
</div>
<div class="row">
<div class="col">
<label for="pass">Password:</label>
</div>
<div class="col after">
<input type="password" name="pass" id="pass"/>
</div>
</div>
<div class="row">
<div class="col">
</div>
<div class="col">
<input type="reset" class ="resetButton"/>
<input type="submit" value = "Login" class="submitButton"/>
</div>
</div>
</div>
</fieldset>
</form>
</div>