Indenting Subsequent Lines of Wrapped Label Text
When faced with constraints on form width, label text can wrap onto multiple lines, leading to aesthetic concerns. While the first line is indented due to the presence of an input element, subsequent lines may not be, creating an uneven appearance.
To achieve indented second and subsequent lines using only CSS, consider using the following approach:
Enclose both the input element and its label within a parent container with the class "checkbox-field". Set the display property of this parent to "flex" and the flex-direction to "row".
.checkbox-field {
display: flex;
flex-direction: row;
}
Example usage:
<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>
This solution flexibly adjusts label text to the available width while maintaining a consistent visual appearance.
부인 성명: 제공된 모든 리소스는 부분적으로 인터넷에서 가져온 것입니다. 귀하의 저작권이나 기타 권리 및 이익이 침해된 경우 자세한 이유를 설명하고 저작권 또는 권리 및 이익에 대한 증거를 제공한 후 이메일([email protected])로 보내주십시오. 최대한 빨리 처리해 드리겠습니다.
Copyright© 2022 湘ICP备2022001581号-3