css - html - how to left align labels? -
i'm trying left align labels keeping input-fields right-aligned without success! able align labels or input-fields not both of them! i've tried lot of things nothing worked
html:
<body style="background-color:lightgray;"> <center> <div class="form-style-2"> <div class="form-style-2-heading">info</div> <form action="" method="post"> <label for="cod"><span>cod <span class="required">*</span></span><input type="text" class="input-field" name="cod" value="" /></label> <label for="name" ><span>name <span class="required">*</span></span><input type="text" class="input-field" name="name" value="" /></label> <label for="phone"><span>phone <span class="required">*</span></span><input type="text" class="input-field" name="phone" value="" /></label> <label for="address"><span>address <span class="required">*</span></span><input type="text" class="input-field" name="address" value="" /></label> <label><span> </span><input type="submit" value="submit" /></label> </form></center> </div> </body>
css
.form-style-2{ max-width: 500px; padding: 20px 12px 10px 20px; font: 13px arial, helvetica, sans-serif; } .form-style-2-heading{ font-weight: bold; font-style: italic; border-bottom: 2px solid #000; margin-bottom: 20px; font-size: 15px; padding-bottom: 3px; } .form-style-2 label{ display: block; margin: 0px 0px 15px 0px; } .form-style-2 label > span{ width: 100px; font-weight: bold; float: left; padding-top: 8px; padding-right: 5px; } .form-style-2 span.required{ color:red; } .form-style-2 input.input-field{ width: 48%; } .form-style-2 input.input-field, .form-style-2 .textarea-field{ box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; border: 1px solid #c2c2c2; box-shadow: 1px 1px 4px #ebebeb; -moz-box-shadow: 1px 1px 4px #ebebeb; -webkit-box-shadow: 1px 1px 4px #ebebeb; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; padding: 7px; outline: none; } .form-style-2 .input-field:focus, .form-style-2 .textarea-field:focus{ border: 1px solid #0c0; } .form-style-2 .textarea-field{ height:100px; width: 55%; } .form-style-2 input[type=submit], .form-style-2 input[type=button]{ border: none; padding: 8px 15px 8px 15px; background: #4caf50; color: #fff; box-shadow: 1px 1px 4px #dadada; -moz-box-shadow: 1px 1px 4px #dadada; -webkit-box-shadow: 1px 1px 4px #dadada; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; } .form-style-2 input[type=submit]:hover, .form-style-2 input[type=button]:hover{ background: #ea7b00; color: #fff; }
jfiddle: https://jsfiddle.net/uv21fc5o/
align text left so:
css
.form-style-2 label > span { text-align: left; }
Comments
Post a Comment