Solved

Html5 with Bootstrap

Posted on 2014-02-13
6
624 Views
Last Modified: 2014-02-13
I am designing a web  page with HTML5 using bootstrap and have a checkbox and dropdown  and these  are aligned right (see attached screenshot) to the page layout.

I need sample working code to achieve this using html5 and bootstrap.

Thanks in Advance
Form.jpg
0
Comment
Question by:ksd123
  • 3
  • 3
6 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
This does the trick but I would guess you have other code as well.  If this is not what you need, then please update the jsbin with the code you do have now.
http://jsbin.com/vusix/1/edit?html,output
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" />
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>

<div class="container">
  <div class="row">
 
      <div class="col-xs-2  pull-right">
     <select>
       <option>stuff</option>
       <option>stuff</option>
       <option>stuff</option>
     </select>
  </div>
    <div class="col-xs-4 col-sm-2 pull-right"><input type="checkbox"> Checkbox</div>
 
  
</div>
  </div>
</body>
</html>

Open in new window

0
 

Author Comment

by:ksd123
Comment Utility
Thank you.I have a minor change to the above form, just I need a lable (select country) for the dropdown after checkbox.

I have a question in the above code, in the form I have "checkbox" first and then "dropdown" but it seems we have first "div" for dropdown and then for "chekcbox" .
Is there any specific reason to do this way?
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
> I need a lable (select country) for the dropdown after checkbox.
You would just add your <label> tag prior to the field

>in the form I have "checkbox" first and then "dropdown" but it seems we have first "div" for dropdown and then for "chekcbox"
I simply made the output look similar to your image.  When you view the output, you can see that it matches.  The reason why it is reversed in the code is because of the, "pull-right".

http://jsbin.com/vusix/2/
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" />
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  
<div class="container">
  <div class="row">
 
      <div class="col-xs-3  pull-right">
        <label>Select Stuff</label>
     <select>
       <option>stuff</option>
       <option>stuff</option>
       <option>stuff</option>
     </select>
  </div>
    <div class="col-xs-4 col-sm-2 pull-right"><input type="checkbox"> Checkbox</div>
 
  
</div>
  </div>
</body>
</html>

Open in new window

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:ksd123
Comment Utility
Actually there is  lot of space between checkbox and dropdown  and need space  similar to screenshot and also label (Select Stuff) should not be in BOLD, I  tried  to resolve these issues  but in vain . Please help.
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 200 total points
Comment Utility
You can adjust the "space" by playing with the classes.  Please read through http://getbootstrap.com/css/ and understand how the grid works.  It is responsive and as the viewport changes, so will the displayed output.  The grid is 12 columns so you will see classes like <div class="col-sm-4 col-xs-12">.  The first means if the viewport is small, set the block to 4 columns, if the viewport is extra small, set the block to the full width(12 columns).  It is all very nicely explained.  

Your code has 2 columns.  If you play with the numbers col-xs-3 you can see what best fits your needs.
<div class="col-xs-3  pull-right">
<div class="col-xs-4 col-sm-2 pull-right">

Open in new window


The bold is a result of using the label tag.  You can either create a separate custom style sheet and place it below the the bootstrap css or add <style>tags below the bootstrap css.
At the very least you should set the label to font-weight:normal
http://jsbin.com/vusix/3/
label{font-weight:normal;}

Open in new window

http://www.w3schools.com/cssref/pr_font_weight.asp
0
 

Author Closing Comment

by:ksd123
Comment Utility
Thank you
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now