Zhengquan Bai
Zhengquan Bai

Reputation: 1073

How can I make the html element always wrap the content?

enter image description here

You see, when the browser width is narrow enough, the scrollbar appears. When I drag the scrollbar to the right, the content exceeds the html element. Here's the code:

body {
  border: 1px solid;
}
lkjlaksjfklajfkalsdddddddaaaadfajflkajflkajflkajflkjasklfjaslkfjaklsjfklasjfklasjfaklsfsd

Upvotes: 1

Views: 42

Answers (1)

dfsq
dfsq

Reputation: 193261

You could use word-break: break-all; rule to make sure long words don't overflow outside the container:

body {
  border: 1px solid;
  word-break: break-all;
}
lkjlaksjfklajfkalsdddddddaaaadfajflkajflkajflkajflkjasklfjaslkfjakjfklasjfklasjfaklsfsdasdfasdfadsfasdfasdfadfasdfadsfasd

Upvotes: 2

Related Questions