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>
Related
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>
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;
}
I have a flexbox row with boxes that looks like this.
How to make it as options? So when you click on one of them, you check checkbox and the chosen box is highlighted.
JSFiddle
<ul class="flex-container longhand">
<li class="flex-item">1</li>
<li class="flex-item">2</li>
<li class="flex-item">3</li>
<li class="flex-item">4</li>
<li class="flex-item">5</li>
</ul>
CSS
.flex-container {
padding: 0;
margin: 0;
list-style: none;
display: flex;
}
.longhand {
flex-flow: wrap row;
}
.flex-item {
color: #C3D0D9;
border: 1px solid #C3D0D9;
width: 50px;
height: 50px;
font-size: 1.3em;
text-align: center;
padding: 10px;
}
Here is a solution using jQuery
I added data-id attributes which are not needed for this feature but can be useful if you need to capture that later or if the elements are generated from your db
$(document).ready(function() {
$('.flex-item').on('click', function() {
//console.log($(this).data('id'));
$(this).toggleClass('active');
/*if(!$('#check_'+$(this).data('id')+':checked')){
$('#check_'+$(this).data('id')).prop('checked', true);
}else {
$('#check_'+$(this).data('id')).prop('checked', false);
}*/
var checkBox = $('#check_' + $(this).data('id'));
checkBox.prop("checked", !checkBox.prop("checked"));
})
})
.flex-container {
padding: 0;
margin: 0;
list-style: none;
display: flex;
}
.longhand {
flex-flow: wrap row;
}
.flex-item {
color: #C3D0D9;
border: 1px solid #C3D0D9;
width: 50px;
height: 50px;
font-size: 1.3em;
text-align: center;
padding: 10px;
}
.active {
border: 1px solid red;
}
#hidden_form {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="flex-container longhand">
<li class="flex-item" data-id="1">1</li>
<li class="flex-item" data-id="2">2</li>
<li class="flex-item" data-id="3">3</li>
<li class="flex-item" data-id="4">4</li>
<li class="flex-item" data-id="5">5</li>
</ul>
<form id="hidden_form">
<input type="checkbox" name="check[]" id="check_1" value="1" />
<input type="checkbox" name="check[]" id="check_2" value="2" />
<input type="checkbox" name="check[]" id="check_3" value="3" />
<input type="checkbox" name="check[]" id="check_4" value="4" />
<input type="checkbox" name="check[]" id="check_5" value="5" />
</form>
I have an <ul> with a height:100%, that doesn't resize itself to fit all of its children <li> elements.
What is happening:
Scrolling through questions, you can see the background color for the <ul> does not fill to the bottom of the last <li>.
What I would like to see happen:
A scrollable unordered list <ul> that surrounds and encloses all <li> elements.
Additional Info:
There is a general wrapper <div> that encloses an unordered list <ul> of <li>, made up of a label <label> and an input <input>. All of this sits between and header and footer, <header> and <footer> respectively.
You can check this CodePen here.
* {
border: 0;
font-family: "Lucida Console", Monaco, monospace
}
body {
min-width: 1440px;
height: 100%;
//background: #bbb
}
header {
width: 100%;
height: 60px;
background: #bada55;
margin: 0;
position: fixed;
top: 0;
left: 0;
z-index: 100;
//opacity: .4;
}
footer {
width: 100%;
height: 100px;
background: #bada55;
margin: 0;
position: fixed;
bottom: 0;
left: 0;
z-index: 100;
//opacity: .4;
}
ul,
li {
list-style-type: none;
color: #444;
display: block;
}
label,
input {
display: block;
position: relative;
}
#wrap {
background: #000;
width: 40%;
height: 100%;
position: absolute;
margin: 0;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#question_list {
width: 100%;
min-width: 452px;
height: 100%;
background: #bada55;
padding: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: 0;
}
.question {
background: #ddd;
width: 90%;
height: 120px;
position: relative;
left: 50%;
transform: translateX(-50%);
margin: 0
}
.question label {
font-size: 24px;
text-align: center;
}
.question input {
width: 284px;
left: 50%;
transform: translateX(-50%);
border-radius: 4px;
font-size: 24px;
margin-top: 44px;
margin-bottom: 24px
}
.space {
width: 100%;
height: 120px;
background: #badff5
}
<header></header>
<div id="wrap">
<ul id="question_list">
<li id="space_0" class="space"></li>
<li id="one" class="question">
<label for="f_name">First Name</label>
<input name="f_name" id="f_name" />
</li>
<li id="space_1" class="space"></li>
<li id="two" class="question">
<label for="l_name">Last Name</label>
<input name="l_name" id="l_name" />
</li>
<li id="space_2" class="space"></li>
<li id="three" class="question">
<label for="age">Age</label>
<input name="age" id="age" />
</li>
<li id="space_3" class="space"></li>
<li id="four" class="question">
<label for="address">Address</label>
<input name="address" id="address" />
</li>
<li id="space_4" class="space"></li>
<li id="five" class="question">
<label for="degree">Degree</label>
<input name="degree" id="degree" />
</li>
<li id="space_5" class="space"></li>
<li id="six" class="question">
<label for="exp">Years of Experience</label>
<input name="exp" id="exp" />
</li>
<li id="space_6" class="space"></li>
</ul>
</div>
<footer></footer>
In order to achieve the intended result you need to add a simple css rule:
ul {
overflow: auto;
}
You can learn more about the overflow css property here
Check codePen demo
I update this content with a new Jsfidle to show the issue with a max-width of 300px.
On a responsive design, I need to add the "span" tag in front of my radio buttons in order to align my input content with my custom checkbox background.
To review the issue, reduce the windows browser until an option is displayed on two lines
HTML
<ul id="sectors">
<li id="title"><p class="f32l32">Sectors</p></li>
<li>
<label class="search-radio-button f15l18">
<input value="61" name="sectors[]" type="radio" class="radio sectors-radio-button"> Built environment
<span class="Built environment"></span>
</label>
</li>
<li>
<label class="search-radio-button f15l18">
<input value="62" name="sectors[]" type="radio" class="radio sectors-radio-button"> Defence & government
<span class="Defence & government"></span>
</label>
</li>
<li>
<label class="search-radio-button f15l18">
<input value="63" name="sectors[]" type="radio" class="radio sectors-radio-button"> Manufacturing & technology
<span class="Manufacturing & technology"></span>
</label>
</li>
<li>
<label class="search-radio-button f15l18">
<input value="64" name="sectors[]" type="radio" class="radio sectors-radio-button"> Oil, energy & mining
<span class="Oil, energy & mining"></span>
</label>
</li>
<li>
<label class="search-radio-button f15l18">
<input value="65" name="sectors[]" type="radio" class="radio sectors-radio-button"> Transport
<span class="Transport"></span>
</label>
</li>
<li>
<label class="search-radio-button f15l18">
<input value="66" name="sectors[]" type="radio" class="radio sectors-radio-button"> Utilities & infrastructure
<span class="Utilities & infrastructure"></span>
</label>
</li>
CSS
ul#sectors, ul#locations {
display: inline-block;
padding-bottom: 2.5%;
}
#detail-search-container li#title {
width: 100%;
display: inline-block;
padding-bottom: 5%;
padding-top: 6%;
}
#detail-search-container li {
min-height: 20px;
width: 50%;
float: left;
display: inline-block;
}
#detail-search-container li label {
padding-left: 20px;
display: inline-block;
padding-left: 20%;
width: 80%;
}
.search-radio-button span {
width: 20px;
width: 22px;
height: 22px;
float: left;
background: url("http://satafx.com/img/radio.gif");
background-repeat: no-repeat;
margin-bottom: 10px;
margin-top: -3px;
display: inline-block;
margin-left: -20%;
}
.search-radio-button input {
display: none;
}
.search-radio-button input:checked + span, .class_checkbox.checked {
background-position: 0px -20px;
background-position: 0px -26px;
}
I have made some cosmetic changes to your CSS as i'm mentioning below with comments.
1) Remove background-position:
.search-radio-button input:checked + span, .class_checkbox.checked {
background-position: 0px -20px;
background-position: 0px -26px; // remove this
}
2) Set margin-top and left acordingly
.search-radio-button span {
width: 20px;
width: 22px;
height: 22px;
float: left;
background: url("http://satafx.com/img/radio.gif");
background-repeat: no-repeat;
margin-bottom: 10px;
margin-top: 0; //change this
display: inline-block;
margin-left: -9%; //change this
}
Fiddle Demo
Updated Fiddle
Hope you want like this!
If I understand correctly, I just have to put the span before the input...
<li>
<label class="search-radio-button f15l18">
<span class="Built environment"></span>
<input value="61" name="sectors[]" type="radio" class="radio sectors-radio-button"> Built environment
</label>
</li>
I hope this is what you are looking for...