Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to fit text inside div box without overflowing

I’ve been creating a display area for an out, but the text keeps on overflowing out and I can’t seem to figure out why. I’ve been researching for a long time, but nothing works. I’ve tried word-wrap: break-word;, tried manually changing the width, etc., but it does not work. What should I use to help fit it inside the box’s container?

  • Note – Total is an output value off of the user’s input
#total {
  border-radius: 5px;
  background-color: lightgrey;
  width: 300px;
  border: 15px solid green;
  padding: 50px;
  margin: 20px;
  word-wrap: break-word;
}
<p id="total" style="position: absolute; right: 400px; width:200px; height: 200px; font-size: 10px;"></p>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Add Overflow-y:auto;

#total {
  border-radius: 5px;
  background-color: lightgrey;
  width: 300px;
  border: 15px solid green;
  padding: 50px;
  margin: 20px;
  word-wrap: break-word;
  overflow-y:auto;

}
<p id="total" style="position: absolute; right: 400px; width:200px; height: 200px; font-size: 10px;">HEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjalHEllloo sdadsasdlkmjal</p>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading