html - How to place labels below buttons and consistently align the two horizontally? -
i'm using margins on individual labels align them centred , directly below buttons. hacky , inconsistent on different screen sizes.
<div id="langbuttons"> <input class="btn-group langbutton" id="usejavascript" value="javascript" type="button"></input> <input class="btn-group langbutton" id="useruby" value="ruby" type="button"></input> <input class="btn-group langbutton" id="usepython" value="python" type="button"></input> <input class="btn-group langbutton" id="usehtml" value="html" type="button"></input> <input class="btn-group langbutton" id="usecss" value="css" type="button"></input> <input class="btn-group langbutton" id="useswift" value="swift" type="button"></input> </div> <div id="langdescriptions"> <label style="margin-left: 4.8%" class="langdescription" id="javascript">javascript</label> <label style="margin-left: 6.8%" class="langdescription" id="ruby">ruby</label> <label style="margin-left: 4.5%" class="langdescription" id="python">python</label> <label style="margin-left: 5.4%" class="langdescription" id="html">html</label> <label style="margin-left: 5.3%" class="langdescription" id="css">css</label> <label style="margin-left: 4.8%" class="langdescription" id="swift">swift</label> </div>
there must better way?
just put them in parent element text-align: center
input
tags self closing -- don't need </input>
here example of mean: https://jsfiddle.net/ajc8pqh9/
.grouping{ display: inline-block; text-align: center; } .langdescription{ display: block; }
<div id="langbuttons"> <div class="grouping"> <input class="btn-group langbutton" id="usejavascript" value="javascript" type="button"> <label for="usejavascript" class="langdescription" id="javascript">javascript</label> </div> <div class="grouping"> <input class="btn-group langbutton" id="useruby" value="ruby" type="button"> <label class="langdescription" id="ruby">ruby</label> </div> <div class="grouping"> <input class="btn-group langbutton" id="usepython" value="python" type="button"> <label class="langdescription" id="python">python</label> </div> <div class="grouping"> <input class="btn-group langbutton" id="usehtml" value="html" type="button"> <label class="langdescription" id="html">html</label> </div> <div class="grouping"> <input class="btn-group langbutton" id="usecss" value="css" type="button"> <label class="langdescription" id="css">css</label> </div> <div class="grouping"> <input class="btn-group langbutton" id="useswift" value="swift" type="button"> <label class="langdescription" id="swift">swift</label> </div> </div>
Comments
Post a Comment