Solved

Html5 with Bootstrap

Posted on 2014-02-13
6
638 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
ID: 39855642
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
ID: 39855688
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
ID: 39855718
> 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:ksd123
ID: 39855757
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
ID: 39855824
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
ID: 39855852
Thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Call a function within the ASP code 4 19
Asp in server side with Mssql Server 7 4 27
html border input line 7 13
Need output in powershell ( Vertical format) 2 20
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

839 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