Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Html5 with Bootstrap

Posted on 2014-02-13
6
Medium Priority
?
687 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 54

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 54

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 800 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
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.
Suggested Courses

824 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