html - Legend Tag Not Rendering Correctly With Bootstrap Grid -
i want use legend html tag visually wrap set of similar inputs in form. should similar how when 1 uses legend attribute without bootstrap, like shown here.
i made bootply example which here. 1 can see: trying create legend wraps first name , last name input fields. styling not right.
i did @ this question, different mine because attempting use legend within grid.
here's way using custom css. add css, , add .customlegend fieldset have legend want display way. adjust positioning, padding, etc needed.
.customlegend { border: 1px solid #e5e5e5; padding: 2em 0 1em; margin-top: 2em; position: relative; } .customlegend legend { border: 0; background: #fff; width: auto; transform: translatey(-50%); position: absolute; top: 0; left: 1em; padding: 0 .5em; } <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <div class="container"> <form> <fieldset class="customlegend row"> <legend>enter name</legend> <div class="form-group col-sm-6"> <label for="first_name">first name:</label> <input type="text" class="form-control" id="email"> </div> <div class="form-group col-sm-6"> <label for="last_name">last name:</label> <input type="text" class="form-control" id="pwd"> </div> </fieldset> <div class="form-group"> <label for="email">email address:</label> <input type="email" class="form-control" id="email"> </div> <div class="form-group"> <label for="pwd">password:</label> <input type="password" class="form-control" id="pwd"> </div> <button type="submit" class="btn btn-default">submit</button> </form> </div>
Comments
Post a Comment