在本文中,我们将学习如何使用 CSS 的属性来断行任何语句。您必须知道 HTML 中用于断行的
标记。但在本文中,我们将仅使用 CSS 来执行此任务。
我们在 CSS中使用单词– break属性,用于指定单词到达行尾时应如何断开或拆分。这个词– Wrap属性是用来分割/打破长的单词,并将其包装到下一行。溢流–涡卷CSS属性是适用于内联元素&指定浏览器可断开所选元素中的线成多行以其它牢不可破地方。
.word {
width: 200px;
overflow-wrap: break-word;
word-wrap: break-word;
word-break: break-word;
}
在这个 CSS 中,我们需要指定一个从换行开始的宽度。在上面的代码中,换行将在宽度达到 200px 后开始。
示例 1:当宽度为 200px 时
HTML
GATE(Graduate Aptitude in Engineering)
is one the most important and in-demand
entrance exam for engineering graduates
in our country. Geeksforgeeks is here
to guide you through the GATE Computer
Science Engineering preparation.
Geeksforgeeks brings you the Complete
GATE preparation course GATE-CS Test
Series 2022, which will help the GATE
aspirants to boost their GATE score
and AIR.An extensive Online Test Series
for GATE CSE to boost your preparation.
Test series is designed considering the
pattern of previous years GATE papers
and ensures to resemble with the
standard of GATE 2022 exam.
HTML
GATE(Graduate Aptitude in Engineering)
is one the most important and in-demand
entrance exam for engineering graduates
in our country. Geeksforgeeks is here
to guide you through the GATE Computer
Science Engineering preparation.
Geeksforgeeks brings you the Complete
GATE preparation course GATE-CS Test
Series 2022, which will help the GATE
aspirants to boost their GATE score
and AIR.An extensive Online Test Series
for GATE CSE to boost your preparation.
Test series is designed considering the
pattern of previous years GATE papers
and ensures to resemble with the
standard of GATE 2022 exam.
输出:在这个例子中,在 200px 之后有一个换行符。
示例 2:当宽度为 500px 时
HTML
GATE(Graduate Aptitude in Engineering)
is one the most important and in-demand
entrance exam for engineering graduates
in our country. Geeksforgeeks is here
to guide you through the GATE Computer
Science Engineering preparation.
Geeksforgeeks brings you the Complete
GATE preparation course GATE-CS Test
Series 2022, which will help the GATE
aspirants to boost their GATE score
and AIR.An extensive Online Test Series
for GATE CSE to boost your preparation.
Test series is designed considering the
pattern of previous years GATE papers
and ensures to resemble with the
standard of GATE 2022 exam.
输出:在这个例子中,500px 后有一个换行符。