I have the following automatically-generated HTML:
http://jsfiddle.net/BrV8X/
What is the advised way, using CSS, to indent the label so that there's some white space under the radio button?
If you prefer using [spacebar] to indent your code rather than using [tab], you can select multiple lines by holding the [alt] key and clicking on the beginning of each line you want to indent. Then, you can press [spacebar] and all the selected lines will be affected. omg it moves!
Output: Method 2: By making the position relative to the first line, set the text-indent to -26px and padding-left value to 26px. Here in this example, we have made the position of the second line relative to the first line. So the second line is indented/aligned according to the first line.
To create a multi-line text input, use the HTML <textarea> tag. You can set the size of a text area using the cols and rows attributes. It is used within a form, to allow users to input text over multiple rows.
label {
display: block;
margin-left: 20px;
}
input {
float: left;
margin-left: -20px;
margin-right: 7px;
}
Here's the fiddle: http://jsfiddle.net/hrfmt/ . Play with the values.
EDIT:
If all the browsers you need to support can understand display: inline-block
, use that instead of float
.
label {
position:relative;
padding-left:20px;
display:block;
}
label input[type=radio] {
position:absolute;
top:4px;
left:0px;
}
http://jsfiddle.net/BrV8X/4/
Here's an example of how to do that without resorting to floats. You'll have to do some magic with negative margins with this approach.
input {
display: inline-block;
margin-right: -100px;
/* The 2 below properties are just for "correct" vertical placement of the button. */
margin-top: 5px;
vertical-align: top;
}
label {
display: inline-block;
margin-left: 100px;
margin-right: -100px;
}
div {
/* Just some spacing between the radio buttons. */
margin-bottom: 5px;
}
http://jsfiddle.net/4osbp0mo/2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With