Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Label text is wrapped but not indent second line

I have a form with limited width, however the label text maybe longer than form width, so the text was wrapped to multiple lines. My problem is that first line is indented because of input element but second line is not, it makes the form not nice.

Do you have any idea to make the second, third ... will be indented as first line, only use CSS?

Actual:

enter image description here

My Expectation is

enter image description here

This is my example for the case:

http://jsbin.com/UvaqISO/2/edit

like image 557
Khoi Nguyen Avatar asked Dec 04 '13 07:12

Khoi Nguyen


People also ask

How do you indent the second line of a paragraph in CSS?

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.

Why is word indenting the second line?

It sounds like you have "hanging indents." Under the View tab, turn on display of Rulers. Click in one of the paragraphs and then right-click and choose Paragraph. You should be able to see the indent settings that are reflected on the horizontal ruler.


2 Answers

Edit your css like this:

.form {
  width: 300px;
}
label {
  display: block;
  margin-top: -20px;
  margin-left: 20px;
}
like image 174
Marinus Avatar answered Sep 25 '22 12:09

Marinus


Something like this.

.checkbox-field {
    display: flex;
    flex-direction: row;
}
<div class="checkbox-field">
    <input type="checkbox" id="check">
    <label for="check">Field 2 Label, may be longer than normal, This is an example for this lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem</label>
</div>
like image 42
Дима Телси Avatar answered Sep 21 '22 12:09

Дима Телси