Bootstrap 4 : Float custom-checkbox to right of the text - html

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<div class="card attribute filter-panel" data-type="select" data-id="1">
<div class="card-header">
<i class="fa fa-angle-down pull-right"></i>
<span class="card-title">color</span>
</div>
<div class="card-body" style="padding: 0px; padding-top: 15px">
<ul class="filter-ul">
<li>
<div class="custom-control custom-checkbox" style="direction: rtl ; text-align: right">
<input type="checkbox" class="custom-control-input filter-checkbox " id="customCheck1" value="1">
<label class="custom-control-label " for="customCheck1">red</label>
</div>
</li>
<li>
<div class="custom-control custom-checkbox" style="direction: rtl ; text-align: right">
<input type="checkbox" class="custom-control-input filter-checkbox " id="customCheck2" value="2">
<label class="custom-control-label " for="customCheck2">blue</label>
</div>
</li>
<li>
<div class="custom-control custom-checkbox" style="direction: rtl ; text-align: right">
<input type="checkbox" class="custom-control-input filter-checkbox " id="customCheck3" value="3">
<label class="custom-control-label " for="customCheck3">green</label>
</div>
</li>
</ul>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
Current position
I want the checkboxes to float to the right of the text, I have tried float:right obviously didn't work.
how can i float them to the right ?

I use postition: absolute to move your boxes to right side and content to left side, hope this heck is work great.
You can play with right CSS property to get exact result you want.
.custom-control-label::before ,.custom-control-label::after {
right: 0;
}
label span {
position: absolute;
right: 21px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="card attribute filter-panel" data-type="select" data-id="1">
<div class="card-header">
<i class="fa fa-angle-down pull-right"></i>
<span class="card-title">color</span>
</div>
<div class="card-body" style="padding: 0px; padding-top: 15px">
<ul class="filter-ul">
<li>
<div class="custom-control custom-checkbox" style="direction: rtl ; text-align: right">
<input type="checkbox" class="custom-control-input filter-checkbox " id="customCheck1" value="1">
<label class="custom-control-label " for="customCheck1"><span>red</span></label>
</div>
</li>
<li>
<div class="custom-control custom-checkbox" style="direction: rtl ; text-align: right">
<input type="checkbox" class="custom-control-input filter-checkbox " id="customCheck2" value="2">
<label class="custom-control-label " for="customCheck2"><span>blue</span></label>
</div>
</li>
<li>
<div class="custom-control custom-checkbox" style="direction: rtl ; text-align: right">
<input type="checkbox" class="custom-control-input filter-checkbox " id="customCheck3" value="3">
<label class="custom-control-label " for="customCheck3"><span>green</span></label>
</div>
</li>
</ul>
</div>
</div>

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<div class="card attribute filter-panel" data-type="select" data-id="1">
<div class="card-header">
<i class="fa fa-angle-down pull-right"></i>
<span class="card-title">color</span>
</div>
<div class="card-body" style="padding: 0px; padding-top: 15px">
<ul class="filter-ul">
<li>
<div class="custom-control custom-checkbox" style="direction: rtl ; text-align: right">
<label class="custom-control-label " for="customCheck1">red</label>
<input type="checkbox" class="custom-control-input filter-checkbox " id="customCheck1" value="1" style="float:right">
</div>
</li>
<li>
<div class="custom-control custom-checkbox" style="direction: rtl ; text-align: right">
<label class="custom-control-label " for="customCheck2">blue</label>
<input type="checkbox" class="custom-control-input filter-checkbox " id="customCheck2" value="2"style="float:right">
</div>
</li>
<li>
<div class="custom-control custom-checkbox" style="direction: rtl ; text-align: right">
<label class="custom-control-label " for="customCheck3">green</label>
<input type="checkbox" class="custom-control-input filter-checkbox " id="customCheck3" value="3"style="float:right">
</div>
</li>
</ul>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
Check this code.I set the checkboxes to the right side of text. I think that's what your problem was.I hope this will help you :)

Related

How can I put the label and the input on the same line please?

How can I put the label and the input on the same line please? I would like to get please a spacing of 1,5cm between the label and input also.
By searching here I have to use form-inline but it doesn't work for put the label and input on the same line.
Thank you so much for your tests.
<!DOCTYPE html>
<html>
<head>
<title>HTML CSS JS</title>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
</head>
<body>
<h1 id="welcome">HTML CSS JS</h1>
<div class="col-12 col-md-6 col-lg-3">
<div class="form-group ">
<label for="date">Start date</label>
<div class="input-group">
<input name="beginDate" id="beginDate" type="text" class="form-control"
style="background-color: white;"
(ngModelChange)="changedBeginDateInput($event)" [(ngModel)]="beginDate">
<input id="picker1" class="form-control" placeholder="dd/mm/yyyy" name="dp1"
ngbDatepicker #dp1="ngbDatepicker" [(ngModel)]="begin.validityDate"
(ngModelChange)="changedBeginDate($event)"
style="position: absolute; left: 0; visibility: hidden">
<div class="input-group-append" (click)="dp1.toggle()">
<span class="input-group-text" id="basic-addon2">
<i class="icon-regular i-Calendar-4"></i>
</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-md-6 col-lg-3">
<div class="form-group form-inline">
<label for="date">End date</label>
<div class="input-group">
<input name="beginDate" id="beginDate" type="text" class="form-control"
style="background-color: white;"
(ngModelChange)="changedBeginDateInput($event)" [(ngModel)]="beginDate">
<input id="picker1" class="form-control" placeholder="dd/mm/yyyy" name="dp1"
ngbDatepicker #dp1="ngbDatepicker" [(ngModel)]="begin.validityDate"
(ngModelChange)="changedBeginDate($event)"
style="position: absolute; left: 0; visibility: hidden">
<div class="input-group-append" (click)="dp1.toggle()">
<span class="input-group-text" id="basic-addon2">
<i class="icon-regular i-Calendar-4"></i>
</span>
</div>
</div>
</div>
</div>
</body>
</html>
.form-group {
display: flex;
column-gap: 20px;
margin-bottom: 12px;
}
<!DOCTYPE html>
<html>
<head>
<title>HTML CSS JS</title>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
</head>
<body>
<h1 id="welcome">HTML CSS JS</h1>
<div class="col-12 col-md-6 col-lg-3">
<div class="form-group ">
<label for="date">Start date</label>
<div class="input-group">
<input name="beginDate" id="beginDate" type="text" class="form-control"
style="background-color: white;"
(ngModelChange)="changedBeginDateInput($event)" [(ngModel)]="beginDate">
<input id="picker1" class="form-control" placeholder="dd/mm/yyyy" name="dp1"
ngbDatepicker #dp1="ngbDatepicker" [(ngModel)]="begin.validityDate"
(ngModelChange)="changedBeginDate($event)"
style="position: absolute; left: 0; visibility: hidden">
<div class="input-group-append" (click)="dp1.toggle()">
<span class="input-group-text" id="basic-addon2">
<i class="icon-regular i-Calendar-4"></i>
</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-md-6 col-lg-3">
<div class="form-group form-inline">
<label for="date">End date</label>
<div class="input-group">
<input name="beginDate" id="beginDate" type="text" class="form-control"
style="background-color: white;"
(ngModelChange)="changedBeginDateInput($event)" [(ngModel)]="beginDate">
<input id="picker1" class="form-control" placeholder="dd/mm/yyyy" name="dp1"
ngbDatepicker #dp1="ngbDatepicker" [(ngModel)]="begin.validityDate"
(ngModelChange)="changedBeginDate($event)"
style="position: absolute; left: 0; visibility: hidden">
<div class="input-group-append" (click)="dp1.toggle()">
<span class="input-group-text" id="basic-addon2">
<i class="icon-regular i-Calendar-4"></i>
</span>
</div>
</div>
</div>
</div>
</body>
</html>
Try something like this:
<div class="input date">
<label>Date</label>
<input type="text" for="Date">
</div>
Then make the input class display: flex;
.input {
display: flex;
}
.input label {
margin-right: 20px;
}
is this what u want?
https://jsfiddle.net/jkL6crdm/
.form-group {
display: -webkit-inline-box;
}
.form-group {
display: -webkit-inline-box;
}
<!DOCTYPE html>
<html>
<head>
<title>HTML CSS JS</title>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
</head>
<body>
<h1 id="welcome">HTML CSS JS</h1>
<div class="col-12 col-md-6 col-lg-3">
<div class="form-group ">
<label for="date">Start date</label>
<div class="input-group">
<input name="beginDate" id="beginDate" type="text" class="form-control"
style="background-color: white;"
(ngModelChange)="changedBeginDateInput($event)" [(ngModel)]="beginDate">
<input id="picker1" class="form-control" placeholder="dd/mm/yyyy" name="dp1"
ngbDatepicker #dp1="ngbDatepicker" [(ngModel)]="begin.validityDate"
(ngModelChange)="changedBeginDate($event)"
style="position: absolute; left: 0; visibility: hidden">
<div class="input-group-append" (click)="dp1.toggle()">
<span class="input-group-text" id="basic-addon2">
<i class="icon-regular i-Calendar-4"></i>
</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-md-6 col-lg-3">
<div class="form-group form-inline">
<label for="date">End date</label>
<div class="input-group">
<input name="beginDate" id="beginDate" type="text" class="form-control"
style="background-color: white;"
(ngModelChange)="changedBeginDateInput($event)" [(ngModel)]="beginDate">
<input id="picker1" class="form-control" placeholder="dd/mm/yyyy" name="dp1"
ngbDatepicker #dp1="ngbDatepicker" [(ngModel)]="begin.validityDate"
(ngModelChange)="changedBeginDate($event)"
style="position: absolute; left: 0; visibility: hidden">
<div class="input-group-append" (click)="dp1.toggle()">
<span class="input-group-text" id="basic-addon2">
<i class="icon-regular i-Calendar-4"></i>
</span>
</div>
</div>
</div>
</div>
</body>
</html>
As you're using bootstrap, adding the "d-flex" class to the parent element would do the trick. Like this:
<div class="form-group d-flex">

display checkboxes in grid format

I want to display check boxes in grid format having 3 columns. Something like below
Item1 Item2 Item3
Item Item5 Item6
4
Item7 Item8 Item9
I am able to display it in grid format with the below code but in case of Item7, instead of positioning correctly, it starts displaying it below Item5. Which I don't want to.
Below is the code which I am using
<div class="row" style="margin-top: 15px; padding-bottom: 15px; margin-left: 5px">
<div class="col-md-4 ef-batch-options-text checkbox" ng-repeat="x in samples">
<input type="checkbox" id="user" name="users" value="{{x}}" />
{{x}}
</div>
I have also tried replacing div with ul and <li but still the same result. Please let me know what I am missing.
form {
width: 60px;
display: grid;
grid-gap: 10px;
grid-template-columns: 1fr 1fr 1fr;
}
<form>
<label>
<input type="checkbox" value=""/>item1
</label>
<label>
<input type="checkbox" value=""/>item2
</label>
<label>
<input type="checkbox" value=""/>item3
</label>
<label>
<input type="checkbox" value=""/>item4
</label>
<label>
<input type="checkbox" value=""/>item5
</label>
<label>
<input type="checkbox" value=""/>item6
</label>
<label>
<input type="checkbox" value=""/>item7
</label>
<label>
<input type="checkbox" value=""/>item8
</label>
<label>
<input type="checkbox" value=""/>item9
</label>
</form>
You can use flexbox
Note that you should avoid using inline styles! Create a style.css file, link it with<link rel="stylesheet" href="style.css"> and paste in the following code:
.row {
margin-top: 15px;
padding-bottom: 15px;
margin-left: 5px
display: flex;
flex-wrap: wrap;
flex-basis: 33%;
}
Try Bootstrap grid method,
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="row">
<div class="col-4 text-center">
<input type="checkbox" id="user" name="users" value=""/>item1
</div>
<div class="col-4 text-center">
<input type="checkbox" id="user" name="users" value=""/>item2
</div>
<div class="col-4 text-center">
<input type="checkbox" id="user" name="users" value=""/>item3
</div>
<div class="col-4 text-center">
<input type="checkbox" id="user" name="users" value=""/>item4
</div>
<div class="col-4 text-center">
<input type="checkbox" id="user" name="users" value=""/>item5
</div>
<div class="col-4 text-center">
<input type="checkbox" id="user" name="users" value=""/>item6
</div>
<div class="col-4 text-center">
<input type="checkbox" id="user" name="users" value=""/>item7
</div>
<div class="col-4 text-center">
<input type="checkbox" id="user" name="users" value=""/>item8
</div>
<div class="col-4 text-center">
<input type="checkbox" id="user" name="users" value=""/>item9
</div>
</div>

Truncate on x-overflow inside list item

Is there a way to make the nice text-overflow: ellipsis; work on long names (class name) in my list, adding to this CSS & HTML? Note how the 55026 ID is wrapped below in an ugly fashion on the last time.
.my-list {
width: 275px;
}
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" />
<ul class="list-group my-list">
<li class="preferred-payer list-group-item">
<label class="checkbox-inline">
<input id="option-one" type="checkbox" name="select" value="60054">
<span class="name">Item Name One</span>
</label>
<span class="id pull-right">60054</span>
</li>
<li class="preferred-payer list-group-item">
<label class="checkbox-inline">
<input id="option-one" type="checkbox" name="select" value="00562">
<span class="name">Item Name Two</span>
</label>
<span class="id pull-right">00562</span>
</li>
<li class="preferred-payer list-group-item">
<label class="checkbox-inline">
<input id="option-one" type="checkbox" name="select" value="55026">
<span class="name">A Really Long Item To Truncate </span>
</label>
<span class="id pull-right">55026</span>
</li>
</ul>
You can consider a row/col configuration then add overflow:hidden to truncate the text:
.my-list {
width: 275px;
padding: 0 15px;
}
.my-list>.row {
margin: 0;
}
label {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" />
<ul class="list-group my-list">
<li class="preferred-payer list-group-item row ">
<label class="checkbox-inline col-xs-9">
<input id="option-one" type="checkbox" name="select" value="60054">
<span class="name">Item Name One</span>
</label>
<span class="id pull-right col-xs-3">60054</span>
</li>
<li class="preferred-payer list-group-item row">
<label class="checkbox-inline col-xs-9">
<input id="option-one" type="checkbox" name="select" value="00562">
<span class="name">Item Name Two</span>
</label>
<span class="id pull-right col-xs-3">00562</span>
</li>
<li class="preferred-payer list-group-item row">
<label class="checkbox-inline col-xs-9">
<input id="option-one" type="checkbox" name="select" value="55026">
<span class="name ">A Really Long Item To Truncate </span>
</label>
<span class="id pull-right col-xs-3">55026</span>
</li>
</ul>

horizontally aligned checkbox with input field?

<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
</head>
<body>
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<label for="reference">Reference</label>
<input type="text" class="form-control" id="reference" name="reference" placeholder="Reference">
<div class="input-error form-control-input" style="color: Red; display: none;">Person is required</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label class="checkbox-inline">
<input type="checkbox" value="">Option 1</label>
<div class="input-error form-control-input" style="color: Red; display: none;">Demo is required</div>
</div>
</div>
</div>
</div>
Now i want to aligned checkbox with input field horizontally. I can't figure out after searching.
Here's an example of how you could do it. I put both input fields in a row, where they occupy half of the row with <div class="col-md-6">.
Here is the code
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
<div class="form-group">
<label for="reference">Reference</label>
<div class="row align-middle">
<div class="col-md-6">
<input class="form-control" id="reference" name="reference" placeholder="Reference" type="text">
<div class="input-error form-control-input" style="color: Red; display: none;">Person is required</div>
</div>
<div class="col-md-6">
<label class="checkbox-inline">
<input value="" type="checkbox">Option 1</label>
<div class="input-error form-control-input" style="color: Red; display: none;">Demo is required</div>
</div>
</div>
</div>
</div>
</div>
Here is a working example.
https://codepen.io/anon/pen/KBzLOR
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
</head>
<body>
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<label for="reference">Reference</label>
<div class="row">
<div class="col-md-6">
<input type="text" class="form-control" id="reference" name="reference" placeholder="Reference">
<div class="input-error form-control-input" style="color: Red; display: none;">Person is required</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="checkbox-inline">
<input type="checkbox" value="">Option 1</label>
<div class="input-error form-control-input" style="color: Red; display: none;">Demo is required
</div>
</div>
</div>
</div> <!-- ROW CLOSING TAG -->
</div>
</div>
</div>

Styling Form Radio Buttons and Check Boxes

I have an HTML form. I want the first label asking a question and the list of radio buttons with corresponding labels to appear in one-line. And the second label asking a question and the list of check boxes with corresponding labels to appear in one-line. I have posted my code below. Tell me what do I need to add and how to to the styling in CSS.
.jumbotron{
position:relative;
background : #000 url(background.jpg) center center;
background-size: cover;
overflow:hidden;
margin-bottom:0px;
}
.box{
position:relative;
background-color:#5DBCD2;
width:90%;
margin-top:0.5%;
height:98.5%;
margin-bottom:1%;
margin-left:5%;
margin-right:5%;
}
.navbar{
min-height: 60px;
margin-bottom:0px;
}
.navbar-inverse{
background-color:#00FF00;
border-color:#00FF00;
font-size:150%;
font-weight:bold;
}
.navbar-inverse .navbar-nav>li>a {
color:#000000;
}
.navbar-inverse .navbar-brand {
color: #ff0000;
font-weight: bold;
font-size:150%;
}
.navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:focus, .navbar-inverse .navbar-nav>.active>a:hover{
background-color:#800080;
}
#index .navbar-inverse>.container-fluid>.navbar-collapse>.navbar-nav>.index, #experience .navbar-inverse>.container-fluid>.navbar-collapse>.navbar-nav>.experience, #video .navbar-inverse>.container-fluid>.navbar-collapse>.navbar-nav>.video ,#hkust .navbar-inverse>.container-fluid>.navbar-collapse>.navbar-nav>.hkust ,#feedback .navbar-inverse>.container-fluid>.navbar-collapse>.navbar-nav>.feedback
{
background-color:#ff69b4;
}
.text
{
padding-top:0.5%;
padding-bottom:0.5%;
text-align: center;
}
.form
{
border-radius: 25px;
background-color:#f4f9a6;
margin-left:5%;
margin-right:5%;
width:90%;
height:80%;
margin-top:0.5%;
margin-bottom:1%;
padding-left:10%;
padding-right:10%;
padding-top:10px;
padding-bottom:20px;
}
input[type="text"] {
width: 70%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<b class="navbar-brand">Vivek's Site</b>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="index">Home</li>
<li class="experience">Experience</li>
<li class="video">Videos</li>
<li class="hkust">HKUST Life</li>
<li class="feedback">Feedback</li>
</ul>
</div>
</div>
</nav>
<div class="jumbotron">
<div class="box">
<div class="text">
<h1><u>Feedback Form</u></h1>
</div>
<div class="form">
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="name" placeholder="Enter name">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="position">Position:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="position" placeholder="Enter position">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="organization">Organization:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="organization" placeholder="Enter organization">
</div>
</div>
<div class="align1">
<div class="form-group">
<label class="control-label col-sm-2" for="rate">Please rate the site:</label>
<div class="col-sm-offset-2 col-sm-10">
<div class="radio">
<label><input type="radio" name="optradio1">Excellent</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio2">Very Good</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio3" >Good</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio4">Fair</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio5">Poor</label>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="part">Best Part of Site :</label>
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label><input type="checkbox" value="home">Home</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="experience">Experience</label>
</div>
<div class="checkbox ">
<label><input type="checkbox" value="video">Videos</label>
</div>
<div class="checkbox ">
<label><input type="checkbox" value="hkust">HKUST Life</label>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="part">Best Aspect of Site :</label>
<select class="form-control" id="sel1">
<option>Select</option>
<option value="content">Content</option>
<option value="friendly">User-friendliness</option>
<option value="accessible">Accessibility</option>
<option value="interactive">Interactivity</option>
<option value="design">Design</option>
<option value="time">Load Time</option>
<option value="compatible">Browser Compatibility</option>
</select>
</div>
<div class="form-group">
<label for="comment">Comments for improvement: </label>
<textarea class="form-control" rows="5" id="comment"></textarea>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Submit</button>
<button type="reset" class="btn btn-default">Reset</button>
</div>
</div>
</form>
</div>
</div>
</div>
Namaste vivek,
here are some of changes i made in your markup, no change in your CSS. Its just about your column structure.
Hope it helps you. You can do the same with checkboxes!
<div class="form-group">
<label class="control-label col-sm-2" for="rate">Please rate the site:</label>
<div class="col-sm-10">
<div class="radio col-md-2">
<label><input type="radio" name="optradio1">Excellent</label>
</div>
<div class="radio col-md-2">
<label><input type="radio" name="optradio2">Very Good</label>
</div>
<div class="radio col-md-2">
<label><input type="radio" name="optradio3" >Good</label>
</div>
<div class="radio col-md-2">
<label><input type="radio" name="optradio4">Fair</label>
</div>
<div class="radio col-md-2">
<label><input type="radio" name="optradio5">Poor</label>
</div>
</div>
</div>
I am not sure I understood you well, but I did this FIDDLE for you.
This is the css I added:
/* makes all checkboxes and radio buttons stick to each other */
.radio-container, .radio,
.checkbox-container, .checkbox {
display: inline-block;
float: left;
}
.checkbox:last-child, .radio:last-child{
clear: right;
display: block;
}
.control-label {
display: block;
float: none;
}
.label {
display: block;
clear: left;
float: left!important;
}
and in your html I added the classes defined above in this part:
<div class="form-group">
<label class="label control-label col-sm-2" for="rate">Please rate the site:</label>
<div class="radio-container col-sm-offset-2 col-sm-10">
<div class="radio">
<label><input type="radio" name="optradio1">Excellent</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio2">Very Good</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio3" >Good</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio4">Fair</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio5">Poor</label>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="label control-label col-sm-2" for="part">Best Part of Site :</label>
<div class="checkbox-container col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label><input type="checkbox" value="home">Home</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="experience">Experience</label>
</div>
<div class="checkbox ">
<label><input type="checkbox" value="video">Videos</label>
</div>
<div class="checkbox ">
<label><input type="checkbox" value="hkust">HKUST Life</label>
</div>
</div>
</div>
<div class="form-group">
<label class="label control-label col-sm-2" for="part">Best Aspect of Site :</label>