Reputation: 321
I'm trying to make the paragraphs in .log_area to break the words and not overflow the entire page, to avoid the horizontal page scroll (If needed, horizontal scroll in the .log_area are accepted).
The statement 'word-wrap: break-word;' is not working. Also the 'overflow-x: scroll;' is not working too.
When I disable the flex container, this works. But I need the flex container.
How can I make this work?
<html>
<head>
<style>
.content {
display: flex;
flex-flow: row wrap;
}
.flexitem1 {
background-color: #DDF;
flex: 1 1 auto;
}
.flexitem2 {
flex: 1 1 auto;
}
.log_area {
height: 250px;
background-color: #CFC;
overflow-y: scroll;
overflow-x: scroll;
}
.log_item {
word-wrap: break-word;
}
</style>
</head>
<body>
<div class='content'>
<div class='flexitem1'>
<p>Flex item div 1. It's ok.</p>
</div>
<div class='flexitem2'>
<div class="log_area">
<p class="log_item">First paragraph.</p>
<p class="log_item">Second paragraph: it's so loooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggg</p>
</div>
</div>
</div>
</body>
</html>
Upvotes: 1
Views: 3859
Reputation: 1383
You are using word-wrap: break-word
! This is one long word so you should use word-break: break-all
if you don't want the word to break then use word-break: keep-all
and it will break the space between the words if you don't want some spaces to break use
.
I added both examples in my code below.
Try to change
word-break: break-all
tokeep-all
.
.content {
display: flex;
flex-flow: row wrap;
}
.flexitem1 {
background-color: #DDF;
flex: 1 1 auto;
}
.flexitem2 {
flex: 1 1 auto;
}
.log_area {
height: 250px;
background-color: #CFC;
overflow-y: scroll;
overflow-x: scroll;
}
.log_item {
word-break: keep-all;
}
.long_word {
word-break: break-all;
}
<div class='content'>
<div class='flexitem1'>
<p>Flex item div 1. It's ok.</p>
</div>
<div class='flexitem2'>
<div class="log_area">
<p class="log_item">First paragraph.</p>
<p class="log_item">Second paragraph: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p class="long_word">Second paragraph: This is longgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg</p>
</div>
</div>
</div>
Upvotes: 1
Reputation: 2099
You can add overflow:hidden.
<html>
<head>
<style>
.content {
display: flex;
flex-flow: row wrap;
}
.flexitem1 {
background-color: #DDF;
flex: 1 1 auto;
}
.flexitem2 {
flex: 1 1 auto;
overflow: hidden;
}
.log_area {
height: 250px;
background-color: #CFC;
overflow-y: scroll;
overflow-x: scroll;
}
.log_item {
word-wrap: break-word;
}
</style>
</head>
<body>
<div class='content'>
<div class='flexitem1'>
<p>Flex item div 1. It's ok.</p>
</div>
<div class='flexitem2'>
<div class="log_area">
<p class="log_item">First paragraph.</p>
<p class="log_item">Second paragraph: it's so loooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggg</p>
</div>
</div>
</div>
</body>
</html>
Upvotes: 0