Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Right way to manage inline controls (might involve bootstrap)?

Posted on 2014-10-11
4
Medium Priority
?
189 Views
Last Modified: 2014-10-11
I have a piece of html that produces form controls and I want them lined up on the same line. I think I have no choice but use these block-level tags in order to skin them with bootstrap.

   <div class="container" style="width: 100%; background: #4e4e4e; height: 177px; color: #fff;">
        <form name="input" action="demo_form_action.asp" method="get" style="margin-top: 16px; height: 155px;">
            <div class="input-group"
                 style="margin-left: 100px; width: 200px;">
                <input type="text" name="user" placeholder="Username:" class="form-control">
                <span class="input-group-addon flat">
                    <i class=" glyphicon glyphicon-user">
                    </i>
                </span>
            </div>
            <select class="btn btn-default dropdown-toggle" name="Days" 
          			data-toggle="dropdown" style="margin-left: 20px;">
                <option value="0">Days</option>
                <option>1</option>                <option>2</option>                <option>3</option>
            </select>
            <div class="btn-group btn-block row">
                <button type="button" class="btn btn-default" style="margin-left: 20px;">Default</button>
                <button type="button" class="btn btn-default dropdown-toggle"
                        data-toggle="dropdown">
                    <span class="caret"></span>
                    <span class="sr-only">Toggle Dropdown</span>
                </button>
                <ul class="dropdown-menu" role="menu">
                    <li><a href="#">Action</a></li>
                    <li><a href="#">Another action</a></li>
                    <li><a href="#">Something else here</a></li>
                    <li class="divider"></li>
                    <li><a href="#">Separated link</a></li>
                </ul>
            </div>
            <input type="submit"
                   value="Check Files"
                   style="margin-left: 20px;"
                   class=" btn btn-default btn-primary">
        </form>
    </div>

Open in new window


This renders to:
blocks.png
I spent a lot of time getting it to look better using Float but I suspect there is a better way and one that will give me less grief for responsive. I want it to look like this:

row.png
I want the block of controls to center and, if the windows shrinks, THEN they can start stacking. But I want them on a line when there is room.  Is there a better way than float? Should I be using the bootstrap grid somehow? A toolbar?  Btn-block? This seems like such a straightforward thing that I suspect I might need to take things out rather than add things in.

What's the RIGHT way to inline and center these?
0
Comment
Question by:Kenny Hopton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40375250
Remove btn-block and row from the default dropdown block

Change your username block to
<div style="margin-left: 100px; width: 200px;" class="col-xs-1">
  <div class="input-group">
                <input type="text" name="user" placeholder="Username:" class="form-control">
                <span class="input-group-addon flat">
                    <i class=" glyphicon glyphicon-user">
                    </i>
                </span>
  </div>
            </div>

Open in new window

0
 

Author Comment

by:Kenny Hopton
ID: 40375283
Thanks Gary. Giant improvement over the float workaround. I can work with this.

Was the
class="col-xs-1"

Open in new window

the only thing that can work or does it just have to be a narrow width div?

I'll close this shortly but was hoping to understand it a little better while this question gives us a place to follow up.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40375287
That just floats it, you may as well use the Bootstrap classes rather than writing your own.
0
 

Author Closing Comment

by:Kenny Hopton
ID: 40375297
Fast answer that works.
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

721 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