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...
Related
I have created both a select-box and a searchbar in html. Now I want to place both elements next to each other. I thought this would be possible by placing both elements into another div-container with display set to inline. But this doesn't really solve the issue.
.select-search-container {
display: inline;
}
.select-box {
display: flex;
flex-direction: column;
width: 400px;
}
.search-bar {
max-width: 400px;
border: none;
position: relative;
box-sizing: border-box;
left: calc(98% - 400px);
top: 20px;
}
#searchBarInput {
background: transparent;
padding: 12px 24px;
border-radius: 8px;
border: 2px solid black;
width: 100%;
box-sizing: border-box;
}
.search-bar__icon {
position: absolute;
height: 100%;
left: 90%;
top: 25%;
}
<div class="select-search-container">
<div class="select-box">
<div class="options-container">
<div class="option">
<input type="radio" class="radio" name="category" id="apples">
<label for="apples">apples</label>
</div>
<div class="option">
<input type="radio" class="radio" name="category" id="bananas">
<label for="bananas">bananas</label>
</div>
<div class="option">
<input type="radio" class="radio" name="category" id="lemons">
<label for="lemons">lemons</label>
</div>
</div>
<div class="selected">
Pick a fruit
</div>
</div>
<div class="search-bar" id="searchBar">
<input type="text" placeholder="Search Fruit" id="searchBarInput">
<i class="material-icons search-bar__icon">search</i>
</div>
</div>
As you can see, I have created the select-box using radio-buttons. I like the styling of this better than a normal select-box. Basically, I am showing the selected-div all the time and upon clicking on this div, I show the options-container. The display of the select-box is set to flex, with flex-direction column, as I want the options-container to be placed below the selected-div:
I am trying to place the searchbar next to the select-box. For this purpose I am also playing around with the left-, top- etc. specifiers. It doesn't really work though. When changing the display-type of the wrapper from inline to inline-flex, it kind of works, but the size of my searchbar shrinks and the icon isn't placed where I want it to be. I know this is a very specific question. I am very surprised that it doesn't work though and would really appreciate an explanation.
.select-search-container {
display: flex;
justify-content: space-between;
}
.select-box {
}
.search-bar {
max-width: 400px;
border: none;
position: relative;
box-sizing: border-box;
top: 20px;
}
#searchBarInput {
background: transparent;
padding: 12px 24px;
border-radius: 8px;
border: 2px solid black;
width: 100%;
box-sizing: border-box;
}
.search-bar__icon {
position: absolute;
height: 100%;
left: 90%;
top: 25%;
}
<div class="select-search-container">
<div class="select-box">
<div class="options-container">
<div class="option">
<input type="radio" class="radio" name="category" id="apples">
<label for="apples">apples</label>
</div>
<div class="option">
<input type="radio" class="radio" name="category" id="bananas">
<label for="bananas">bananas</label>
</div>
<div class="option">
<input type="radio" class="radio" name="category" id="lemons">
<label for="lemons">lemons</label>
</div>
</div>
<div class="selected">
Pick a fruit
</div>
</div>
<div class="search-bar" id="searchBar">
<input type="text" placeholder="Search Fruit" id="searchBarInput">
<i class="material-icons search-bar__icon">search</i>
</div>
</div>
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>
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>
.selected_area {
background-color: #c8c8c8;
padding-top:5px;
height: 330px;
border-radius: 5px;
width:233px;
}
<div class="selected_area">
<label>
<input type="checkbox" value="scooter" id=""><div class="label-text fa-lg"><span>ScooterScooterScooterScooterScooter ScooterScooterScooter cooterScooterScooterScooter ScooterScooterScooter</span></div>
</label>
<label>
<input type="checkbox" value="motorcycle" id=""><div class="label-text fa-lg"><span>Motorcycle</span></div>
</label>
<label>
<input type="checkbox" value="downtown 250 en" id=""><div class="label-text fa-lg"><span>DOWNTOWN 250(EN)DOWNTOWN 250(EN)DOWNTOWN 250(EN) DOWNTOWN 250(EN)DOWNTOWN 250(EN)</span></div>
</label>
</div>
How to make my text next to checkbox not under it?
For this you've to write CSS like:
input[type="checkbox"] {
display: inline-block;
width: 15px;
vertical-align: top;
}
.label-text {
display: inline-block;
width: 200px;
word-break: break-all;
}
Also for side-by-side alignment you should use <span> instead of block elements like <div>.
I've created JSFiddle, please have a look.
try this
<div class="selected_area">
<label>
<input type="checkbox" value="scooter" id="">
<span class="label-text fa-lg">
<span>ScooterScooterScooterScooterScooter ScooterScooterScooter cooterScooterScooterScooter ScooterScooterScooter</span>
</span>
<br>
</label>
<label>
<input type="checkbox" value="motorcycle" id="">
Motorcycle
<br>
</label>
<label>
<input type="checkbox" value="downtown 250 en" id="">
DOWNTOWN 250(EN)DOWNTOWN 250(EN)DOWNTOWN 250(EN) DOWNTOWN 250(EN)DOWNTOWN 250(EN)
</label>
</div>
maybe so?
* {
padding: 0;
margin: 0;
}
.selected_area {
background-color: #c8c8c8;
padding:10px;
height: 330px;
border-radius: 5px;
width:233px;
margin: 20px;
}
.selected_area label {
position: relative;
margin: 10px 0;
display: block;
}
.selected_area .label-text {
position: relative;
padding-left: 24px;
}
.selected_area input {
position: absolute;
top: 2px;
left: 0;
}
<div class="selected_area">
<label>
<input type="checkbox" value="scooter" id="">
<div class="label-text fa-lg"><span>ScooterScooterScooterScooter ScooterScooterScooter cooterScooterScooterScooter ScooterScooterScooter</span>
</div>
</label>
<label>
<input type="checkbox" value="motorcycle" id="">
<div class="label-text fa-lg"><span>Motorcycle</span>
</div>
</label>
<label>
<input type="checkbox" value="downtown 250 en" id="">
<div class="label-text fa-lg"><span>DOWNTOWN 250(EN)DOWNTOWN 250(EN)DOWNTOWN 250(EN) DOWNTOWN 250(EN)DOWNTOWN 250(EN)</span>
</div>
</label>
</div>
.label-text.fa-lg {
display: inline-block;
}
check this link for more help on display property
https://css-tricks.com/almanac/properties/d/display/
I have a website and I want to put a footer at the end of each page.
The page login has content, but the footer doesn't remain at the end of it.
login
<div class="login">
<form id="loginForm" method="POST" action="<?php echo URL; ?>Login/run">
<li>
<label>
Username:
</label>
<input type="text" name="username"/>
<span class="errorMessage"></span>
</li>
<li>
<label>
Password:
</label>
<input type="text" name="password"/>
<span class="errorMessage"></span>
</li>
<li>
<label>
Type:
</label>
<select name="typeOfUser">
<option value="1">Restaurant</option>
<option value="2">Customer</option>
</select>
</li>
<li>
<label></label>
<input type="submit" value="Login"/>
</li>
</form>
</div>
css
.login{
position: relative;top: 100px;
margin-left: 280px;
}
.login li{
list-style: none;
padding-bottom: 10px;
}
.login label{
color: blue;
display: inline-block;
width: 100px;
}
.login input{
padding: 0.4em;
}
.login select{
padding: 0.4em;
}
footer
#footerContent{
position: relative;
bottom: 0px;
width: 100%;
height: 48px;
background-color: #646467;
}
change your login div css to
.login{
position: relative;
margin-top: 100px;
margin-left: 280px;
}
and footer will come after login div.
Check this jsfiddle
hope it helps
try this
#footerContent{
position: absolute;
bottom: 0;
width: 100%;
height: 48px;
background-color: #646467;
}