Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text not staying inside div

Tags:

css

I have a div that text will just not stay in and I have no idea why, I have never run into this issue before Im hoping some people can help me out, heres my code:

HTML:

#toronto-content {
  position: relative;
  z-index: 98;
  height: 100%;
  width: 700px;
  background-color: #0A0A0A;
  color: #FFF;
}
<div id="toronto-content">

  Interactively pursue long-term high-impact vortals and distributed systems. Competently streamline team driven testing procedures without leading-edge intellectual capital. Energistically engage market-driven catalysts for change via client-centered technologies.
  Compellingly architect long-term high-impact intellectual capital and resource-leveling interfaces. Phosfluorescently initiate market positioning supply chains with stand-alone processes. Collaboratively generate leading-edge services for synergistic
  e-markets. Conveniently syndicate bleeding-edge resources whereas equity invested scenarios. Collaboratively parallel task backward-compatible deliverables and business relationships. Assertively implement turnkey niche markets for technically sound
  human capital. Collaboratively integrate pandemic niche markets with corporate action items. Quickly utilize timely paradigms after best-of-breed infomediaries. Appropriately drive future-proof initiatives via standards compliant opportunities. Uniquely
  coordinate 24/365 mindshare vis-a-vis top-line synergy. Phosfluorescently benchmark one-to-one mindshare with high-payoff best practices. Distinctively supply principle-centered relationships whereas revolutionary relationships.

</div>

if you want to check out the full site its here: http://lasociete.ca/new/

like image 670
user2820604 Avatar asked Oct 17 '13 19:10

user2820604


People also ask

How do I force text to stay in a div?

You can force the content of the HTML <div> element stay on the same line by using a little CSS. Use the overflow property, as well as the white-space property set to “nowrap”.

How do I keep the contents inside a div?

Just add overflow: auto; to the <ul> . That will make it so that the text doesn't leak outside of the UL. However, depending on what you're doing, it might be easier to just make the <li> display: inline; . It totally depends on what you're doing!

How do I put text inside a div?

Use the insertAdjacentText() method to append text to a div element, e.g. container. insertAdjacentText('beforeend', 'your text here') . The method inserts a new text node at the provided position, relative to the element it was called on.

How do you make text stay in center in CSS?

To center text in CSS, use the text-align property and define it with the value “center.”


3 Answers

This will solve your issue:

#toronto-content {
  white-space: normal;
}

But I would consider putting your text into a <p> or <span> tag.

like image 79
dezman Avatar answered Oct 26 '22 03:10

dezman


That's because the amount of text is larger than the div.
I recommend adding overflow:overlay to your style, this will create a vertical scroll bar right next to the content.

If you add overflow:scroll it will create a horizontal scroll-bar even if there's no need for one.

If that's not what you want, you should either add pages when there's too much content (called "pagination") or make a custom vertical scrollbar with Javascript or jQuery.

like image 25
LasagnaAndroid Avatar answered Oct 26 '22 03:10

LasagnaAndroid


Add this

#toronto-content {
  white-space: normal;
  overflow: hidden;
}
like image 4
Zvi Redler Avatar answered Oct 26 '22 01:10

Zvi Redler