如何在<div>中包含文本?

时间:2017-02-15 14:18:51

标签: html css

我有这个HTML:

<div style="word-wrap: normal; width: 20rem; max-width: 30rem; border: 1px solid red;">
  already, always, very - a word or phrase that modifies or qualifies an adjective, verb, or other adverb or a word group, expressing a relation of place, time, circumstance, manner, cause, degree, etc. (e.g., gently, quite, then, there ).
</div>

如果<div>,我希望文本能够在内部包裹。然而它溢出并且根本没有任何环绕。

有没有办法让它环绕而不是流出<div>的右侧?

2 个答案:

答案 0 :(得分:0)

文字没有溢出,你可以用背景看到它。 您可以通过添加

使其更加规则
text-align: justify; text-align-last: left

&#13;
&#13;
<div style="word-wrap: normal; width: 20rem; max-width: 30rem; background: #cacaca">
      already, always, very - a word or phrase that modifies or qualifies an adjective, verb, or other adverb or a word group, expressing a relation of place, time, circumstance, manner, cause, degree, etc. (e.g., gently, quite, then, there ).
    </div>


<div style="word-wrap: normal; width: 20rem; max-width: 30rem; text-align: justify; text-align-last: left">
      already, always, very - a word or phrase that modifies or qualifies an adjective, verb, or other adverb or a word group, expressing a relation of place, time, circumstance, manner, cause, degree, etc. (e.g., gently, quite, then, there ).
    </div>
&#13;
&#13;
&#13;

答案 1 :(得分:-1)

你想要这个吗?

<div style="word-wrap: normal; width: 15rem; max-width: 30rem; float: left; padding-right: 1rem;">
  already, always, very - a word or phrase that modifies or qualifies an adjective, verb, or other adverb or a word group, expressing a relation of place, time, circumstance, manner, cause, degree, etc. (e.g., gently, quite, then, there ).
</div>
<div style="word-wrap: normal; width: 15rem; max-width: 30rem; float: left;">
  already, always, very - a word or phrase that modifies or qualifies an adjective, verb, or other adverb or a word group, expressing a relation of place, time, circumstance, manner, cause, degree, etc. (e.g., gently, quite, then, there ).
</div>