"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Indent Subsequent Wrapped Label Lines in CSS?

How to Indent Subsequent Wrapped Label Lines in CSS?

Published on 2024-11-08
Browse:720

How to Indent Subsequent Wrapped Label Lines in CSS?

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:

This solution flexibly adjusts label text to the available width while maintaining a consistent visual appearance.

Release Statement This article is reprinted at: 1729725831 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3