Making two lists next to each other - html

I'm currently making a form in HTML and trying to get two lists next to each other. The tricky part is, that the first list is cut in half, so it has 2 columns, while the other doesn't. I cannot fixate the column width for the first one for some reason, and the other list is put after the first one. So how could I fix my code, so it would work as I intended to?
Heres the HTML,CSS code:
.form ul,
li {
margin: 0;
padding: 0;
list-style: none;
column-width: 100px;
column-count: 2;
border-spacing: 50px 0;
border-collapse: separate;
}
.form li+li {
margin-top: 10px;
}
#other ul {
display: inline-block
}
#other ul,
li {
column-count: 1;
column-width: 100px;
margin: 0;
padding: 0;
list-style: none;
}
<div class="form"><br><br>
<form>
<label for="name">Name:</label><br>
<input type="text" id="name" name="name"><br><br><br> Who is gonna be the champion?
<ul>
<li>
<input type="radio" id="ham" name="names" value="Hamilton">
<label for="ham">Hamilton</label>
</li>
<li>
<input type="radio" id="rus" name="names" value="Russell">
<label for="rus">Russell</label>
</li>
...
</ul>
<div id="other">
Which team is gonna be the winner overall?
<ul>
<li>
<input type="radio" id="mer" name="teams" value="Mercedes">
<label for="mer">Mercedes</label>
</li>
<li>
<input type="radio" id="rb" name="teams" value="Red Bull">
<label for="rb">Red Bull</label>
</li>
...
</ul>
</div>
</form>
</div>
Where both using the form class, and the second list using the "other" division too.

You can use flexbox to achieve it
.flexbox {
display: flex;
}
.flexbox div {
flex: 0 0 50%; /* cut divs into half */
}
Your HTML will be possibly like below
<div class="flexbox">
<div>
<p>Question 1</p>
<ul>...</ul>
</div>
<div>
<p>Question 2</p>
<ul>...</ul>
</div>
<div>
.form ul,
li {
margin: 0;
padding: 0;
list-style: none;
column-width: 100px;
column-count: 2;
border-spacing: 50px 0;
border-collapse: separate;
}
.form li+li {
margin-top: 10px;
}
#other {
width: 50%;
margin-left: auto;
}
#other ul {
display: inline-block
}
#other ul,
li {
column-count: 1;
column-width: 100px;
margin: 0;
padding: 0;
list-style: none;
}
#other p {
margin-top: 0;
}
.flexbox {
display: flex;
}
<div class="form"><br><br>
<form>
<label for="name">Name:</label><br>
<input type="text" id="name" name="name"><br><br><br>
<p>Who is gonna be the champion?</p>
<div class="flexbox">
<ul>
<li>
<input type="radio" id="ham" name="names" value="Hamilton">
<label for="ham">Hamilton</label>
</li>
<li>
<input type="radio" id="rus" name="names" value="Russell">
<label for="rus">Russell</label>
</li>
...
</ul>
<div id="other">
<p>Which team is gonna be the winner overall?</p>
<ul>
<li>
<input type="radio" id="mer" name="teams" value="Mercedes">
<label for="mer">Mercedes</label>
</li>
<li>
<input type="radio" id="rb" name="teams" value="Red Bull">
<label for="rb">Red Bull</label>
</li>
...
</ul>
</div>
</div>
</form>
</div>

Add container for your lists, then give this container => display: flex
.form ul,
li {
margin: 0;
padding: 0;
list-style: none;
column-width: 100px;
column-count: 2;
border-spacing: 50px 0;
border-collapse: separate;
}
.form li+li {
margin-top: 10px;
}
#other ul {
display: inline-block
}
#other ul,
li {
column-count: 1;
column-width: 100px;
margin: 0;
padding: 0;
list-style: none;
}
.lists-container{
display: flex
}
<div class="form"><br><br>
<form>
<label for="name">Name:</label><br>
<input type="text" id="name" name="name"><br><br><br>
<div class="lists-container">
<div id="first">
Who is gonna be the champion?
<ul>
<li>
<input type="radio" id="ham" name="names" value="Hamilton">
<label for="ham">Hamilton</label>
</li>
<li>
<input type="radio" id="rus" name="names" value="Russell">
<label for="rus">Russell</label>
</li>
...
</ul>
</div>
<div id="other">
Which team is gonna be the winner overall?
<ul>
<li>
<input type="radio" id="mer" name="teams" value="Mercedes">
<label for="mer">Mercedes</label>
</li>
<li>
<input type="radio" id="rb" name="teams" value="Red Bull">
<label for="rb">Red Bull</label>
</li>
...
</ul>
</div>
</div>
</form>
</div>

Related

Why can I click on a link outside of its text element?

I'm building a forum and I have a link that can be clicked outside of its text, how can I undo it?
I also have an image inside a tag that can be clicked outside of its image, I want to undo that too.
I have tried - position: relative; but it didn't work.
Here is the HTML code of the image.
<div class="nav-list">
<a class="home_A"href="Home.php">
<img class="homeIcon" src="photos/icon.png">
</a>
</div>
CSS of the image
.homeIcon{
width: 200px;
display:block;
margin:auto;
margin: 0 auto;
}
CSS of the <a> link
.signinForm a{
margin: auto;
display:block;
text-align:center;
margin-top: 7px;
color: #006db6;
font-size: 20px;
}
HTML of the <a> link
<form method="POST" class="signinForm">
<ul>
<li> <h1 class="signinH1">sign in</h1></li>
<li> <input type="text" placeholder="User name"name="username_login"class="username" value="<?php if(isset($_POST['username_login'])){echo $_POST['username_login'];}?>" required></li>
<li> <input type="password" placeholder="Password" name="password_login" class="password" value="<?php if(isset($_POST['password_login'])){echo $_POST['password_login'];}?>" required></li>
<li> <input type="submit" value="Log in"class="signinbutton"></li>
<li>Sign up</li>
</ul>
</form>
Thanks all.
It might have to do with your CSS styles for <a> tags and/or <img> tags.
My guess is that something like the following might fix your issue
.homeIcon {
display: inline-block;
}
Try with something like:
img.homeIcon {
display: inline-block;
}
div.home_A {
align-content:center;
margin: 0 auto;
text-align: center; // Not mandatory but useful
}
Assign display: inline-block of course, also use object-fit:contain on <img> and set the line-height: of <a> to 1 to 1.25 depending on how your font is setup but there's very little play in the value.
:root {
font: 1ch/1 'Segoe UI'
}
body {
font-size: 2ch;
}
a {
font-size: 2.5rem;
line-height: 1.15;
}
a,
img {
display: inline-block;
}
img {
object-fit: contain;
width: 3rem;
height: 3rem;
margin-bottom: -3px;
}
<div class='frame'>
<a class="zOne" href="https://stackoverflow.com/users/2813224/zer00ne">
..::Zer00ne::..
<img src='https://i.ibb.co/Kx33pSY/01.jpg'></a>
</div>
<!--HTML_CODE-->
<div class="nav-list">
<a class="home_A"href="Home.php">
<img class="homeIcon" src="photos/icon.png">
</a>
</div>
<form method="POST" class="signinForm">
<ul>
<li> <h1 class="signinH1">sign in</h1></li>
<li> <input type="text" placeholder="User
name"name="username_login"class="username" value="<?php
if(isset($_POST['username_login'])){echo $_POST['username_login'];}?>" required>
</li>
<li> <input type="password" placeholder="Password" name="password_login"
class="password" value="<?php if(isset($_POST['password_login'])){echo
$_POST['password_login'];}?>" required></li>
<li> <input type="submit" value="Log in"class="signinbutton"></li>
<div class="signUp-block">
<li>Sign up</li></div>
</ul>
</form>
/*CSS_CODE*/
.homeIcon{
width: 200px;
display:block;
margin:auto;
margin: 0 auto;
}
.signUp-block{
display: flex;
flex-direction: row;
justify-content: center;
}
.signinForm a{
margin: auto;
display:inline-block;
text-align:center;
margin-top: 7px;
color: #006db6;
font-size: 20px;
}
.homeIcon {
display: inline-block;
}

How to display multiple checkboxes both horizontally and vertically css

I'm trying to set a collection of checkboxes both horizontally and vertically, but they don't come out uniformally.
The labels for each checkbox can vary in size, e.g. one label for a checkbox says "International Casaulty Treaty" whereas another only says WIP.
I was going over this vertical example here.
http://jsfiddle.net/zcuLgbxt/
How to can I neatly arrange them so they are all in alignment both vertically and horizontally?
Thanks very much in advance!
Here is my simple HTML/CSS
li {
margin: 5px;
}
input {
width: 20px;
background-color: blue;
position: relative;
left: 200px;
vertical-align: middle;
}
.vertical-list {
width: 200px;
position: relative;
left: -20px;
display: inline-block;
vertical-align: middle;
}
li{
list-style:none;
}
.horizontal-list{
display: inline;
}
<center>
<ul>
<li>
<input type="checkbox" >
<label class="vertical-list"> label1 label1 label1</label>
<input type="checkbox" >
<label class="horizontal-list" for="myid2">label2</label>
</li>
<li>
<input type="checkbox" >
<label class="vertical-list" >label2label2label2</label>
<input type="checkbox">
<label class="horizontal-list" for="myid2">label2label2</label>
</li>
<li>
<input type="checkbox" >
<label class="vertical-list" > label4 label4 label4</label>
<input type="checkbox" >
<label class="horizontal-list" >label2</label>
</li>
</ul>
</center>
CSS-Tables
li {
margin: 5px;
display: table-row;
}
li * {
display: table-cell;
padding: 0.5em;
}
input {
background-color: blue;
position: relative;
}
.vertical-list {}
li {
list-style: none;
}
.horizontal-list {
display: inline;
}
<ul>
<li>
<input type="checkbox">
<label class="vertical-list"> label1 label1 label1</label>
<input type="checkbox">
<label class="horizontal-list" for="myid2">label2</label>
</li>
<li>
<input type="checkbox">
<label class="vertical-list">label2label2label2</label>
<input type="checkbox">
<label class="horizontal-list" for="myid2">label2label2</label>
</li>
<li>
<input type="checkbox">
<label class="vertical-list"> label4 label4 label4</label>
<input type="checkbox">
<label class="horizontal-list">label2</label>
</li>
</ul>

How to draw a line between radio buttons?

I have been trying to apply the same design on the image below using HTML/CSS and that is what I have achieved so far.
.slider{
display: flex;
margin: 0 auto;
text-align: center;
li {
display: flex;
flex-direction: column;
align-items: center;
padding: 10rem;
}
<ul class="slider">
<li class="slider-item">
<label for="f-option">In Depth Knowledge</label>
<input type="radio" id="f-option">
</li>
<li class="slider-item">
<label for="g-option">Exellence & Education</label>
<input type="radio" id="g-option">
</li>
<li class="slider-item">
<label for="k-option">In Depth Knowledge</label>
<input type="radio" id="k-option">
</li>
</ul>
Use code as below:
Using li{flex: 0 1 33%;} and for line use pseudo as :after
See fiddle
NOTE!
If you want the user can select only one of the radio buttons use name attr
.slider {
display: flex;
margin: 0 auto;
}
label {
width: 80px;
display: block;
}
input {
margin-left: 30px;
margin-right: -1px;
}
li {
flex: 0 1 33%;
list-style: none;
position: relative;
}
li:not(:last-child):after {
content: "";
position: absolute;
height: 1px;
width: 100%;
background: black;
top: 45px;
}
<ul class="slider">
<li class="slider-item">
<label for="f-option">In Depth Knowledge</label>
<input type="radio" id="f-option" name="rb">
</li>
<li class="slider-item">
<label for="g-option">Exellence & Education</label>
<input type="radio" id="g-option" name="rb">
</li>
<li class="slider-item">
<label for="k-option">In Depth Knowledge</label>
<input type="radio" id="k-option" name="rb">
</li>
</ul>

Add icon to end of radio input div

I'm attempting to create a similar UI as below using radio inputs. Most of the UI was fairly easy to recreate, the only exception is adding the arrow (icon?) to the end of the label div. I've attempted to div an arrow in and force it to the center using margins, but it's obviously not a very good solution. What's the best way to add the arrow at the end of the label?
Here's the current code
<div id='results'>
<form>
<input type="radio" name="result" value="1" id='opt-1' checked>
<label for="opt-1"><h3>Option 1</h3>
<p>Short Description of Option 1</p></label><br>
<input type="radio" name="result" value="2" id='opt-2' checked>
<label for="opt-2"><h3>Option 2</h3>
<p>Short Description of Option 2</p></label><br>
<input type="radio" name="result" value="3" id='opt-3' checked>
<label for="opt-3"><h3>Option 3</h3>
<p>Short Description of Option 3</p></label><br>
</form>
</div>
JSFiddle
EDIT:
I'm aware the JSFiddle doesn't apply the background correctly. The code does operate fine on production.
I've created a wrapper of class .list for each radio item to bind the data.
<div id='results'>
<form>
<div class="list">
<span>
<input type="radio" name="result" value="1" id='opt-1' checked>
</span>
<span class="radio-content">
<span>
<label class="mb-1" for="opt-1"><h3>Option 1</h3>
<p class="d-inline">Short Description of Option 1</p></label><br>
</span>
<span class="arrow"><</span>
</span>
</div>
<div class="list">
<span>
<input type="radio" name="result" value="1" id='opt-1' checked>
</span>
<span class="radio-content">
<span>
<label class="mb-1" for="opt-1"><h3>Option2</h3>
<p class="d-inline">Short Description of Option 2</p></label><br>
</span>
<span class="arrow"><</span>
</span>
</div>
</form>
</div>
CSS code here
.list{
display: flex;
align-items:center;
}
.mb-1{
margin-bottom: 8px;
}
.radio-content{
width:100%;
display:flex;
align-items:center;
justify-content: space-between;
}
Instead of "<" you can use the appropriate icon with the appropriate spacing
label {
background-color: #16a085;
background: linear-gradient(to right, #16a085, #66a99c);
width: 80%;
padding-left: 15px;
padding-top: 10px;
margin-bottom: 3px;
}
form > label > h3 {
margin-bottom: 1px;
}
form > label > p {
margin-top: 1px;
}
form > label h3::after {
content: '\276E';
position: absolute;
right: 0;
padding-right: 20px;
}
input[type=radio] {
display: none;
}
<div id='results'>
<form>
<input type="radio" name="result" value="1" id='opt-1' checked>
<label for="opt-1">
<h3>Option 1</h3>
<p>Short Description of Option 1</p>
</label><br>
<input type="radio" name="result" value="2" id='opt-2' checked>
<label for="opt-2">
<h3>Option 2</h3>
<p>Short Description of Option 2</p>
</label><br>
<input type="radio" name="result" value="3" id='opt-3' checked>
<label for="opt-3">
<h3>Option 3</h3>
<p>Short Description of Option 3</p>
</label><br>
</form>
</div>
So flexbox is awesome for layouts like these. It performs well and has great browser support (http://caniuse.com/#search=flexbox). IE has some issues but should be able to work around.
ul {
list-style: none;
width: 400px;
border: 1px solid #ccc;
margin: 0;
padding: 0;
}
ul li {
display: flex;
flex-direction: row;
justify-content: space-between;
border-bottom: 1px solid #ccc;
}
ul li:last-child {
border-bottom: none;
}
.title {
flex-grow: 1;
padding-top: 4px;
}
.title h3 {
margin: 0;
}
.title p {
font-size: 9px;
color: #aaa;
margin: 1px 0 0 0;
}
.icon {
padding-left: 10px;
width: 40px;
line-height: 50px;
display: inline-block;
}
.toggle-switch {
line-height: 50px;
width: 50px;
display: inline-block;
text-align: center;
}
<ul>
<li>
<span class="icon">*</span>
<div class="title">
<h3>Stops</h3>
<p>Non stop, 1 stop, 2+ stops</p>
</div>
<span class="toggle-switch">^</span>
</li>
<li>
<span class="icon">*</span>
<div class="title">
<h3>Duration</h3>
<p>Any</p>
</div>
<span class="toggle-switch">^</span>
</li>
</ul>

How can I center my page but put it at the bottom

.helpdesk ul {
width:750px;
list-style-type:none;
list-style-position:outside;
margin:0px;
padding:0px;
text-align: center;
bottom: 100px;
}
.helpdesk li{
padding:12px;
border-bottom:1px solid #eee;
position:relative;
text-align: center
bottom: 100px;
center: 20px;
}
.helpdesk h2 {
margin: o;
display: inline;
}
.helpdesk label {
width:150px;
margin-top: 3px;
display:inline-block;
padding:3px;
text-align: center;
bottom: 100px;
}
<ul>
<li>
<h2>Help Desk</h2>
</li>
<li>
<label for="name">Name:</label>
<input type="text" name="name" placeholder="John Doe"/>
</li>
<li>
<label for="email">Email:</label>
<input type="text" name="email" placeholder="JohnDoe#example.com" />
</li>
<li>
<label for="website">Phone Number:</label>
<input type="text" name="Phone" placeholder="###-###-####" />
</li>
<li>
<label for="message">Message:</label>
<textarea name="message" cols="40" rows="6">
</textarea>
</li>
<li>
<button class="submit" type="submit">Submit </button>
</li>
</ul>
I'm trying to figure out how to move my UL and Li to the middle bottom of the page can't seem to get it right, is there anyway to do this. I'm tried looking online and its only giving me the bottom left or bottom right, when I need bottom center
add style rule margin:auto to .helpdesk ul selector