CSS override white-space:nowrap on a website - html

A website that I use on a regular basis does this. This causes way to much stuff to be on a single line and it goes off the screen. It needs to do word wrapping but what see below prevents it.
div.dbThreadDetailTreeRowCellItem {
white-space: nowrap;
}
https://stackoverflow.com/a/1258512/985898
I don't want to have to open firebird and fix it every time I go to the website. Is there hopefully an easy way to fix this with your css files? I am using firefox.
https://superuser.com/a/295806/93715
Firefox User Profile Folder --> Chrome -- > userChrome.css
I added this to my userChrome.css file. What do I need to add to my css file?
.break-word {
word-wrap: break-word;
}
-moz-hyphens: auto;
p
{
white-space:normal;
}
.u_nowrap {
white-space: normal !important;
}
pre { white-space: pre-wrap !important; }
Is there also a way to fix this issue in Chrome?

It doesn't look like any of your css rules apply to the container you said is causing the problem.
Try adding this line:
div.dbThreadDetailTreeRowCellItem{ word-wrap: break-word !important; white-space: normal !important; }

Related

Move to newline when tabbing/spacing to end of contenteditable div

Recently I have been having a few issues with using a content editable div as a text box for a project I have been working on. The project is built with Angular2 on the front-end.
The issue I have been having is when I go to tab/space all the way to the end of the content editable div, rather than moving to the next line, it instead keeps adding tabs that appear to accumulate in the text content of the div. By that I mean, if I hit the tab/space key 4 times once it reaches the end, I will then have to backspace 4 times to clear them out.
<div class="text-box" contenteditable="true"></div>
body
{
background-color: black;
}
.text-box
{
background-color: white;
color: black;
height: 200px;
width: 200px;
margin: auto;
white-space: pre-wrap;
}
https://codepen.io/anon/pen/YxYNYW
The code pen I included demonstrates the issue. If you just click inside the box and then hold space bar, once the cursor gets to the end, it will not move to a newline. I realize it has something to do with the white-space: pre-wrap property I use with the content editable div. Is there anyway to get this to work while still being able to use that property?
I would like to keep the pre-wrap property because it preserves all the white-space that is brought in from objects with text in the database. I tried it with the pre-line property over pre-wrap but that caused the text to jump when clicking into the editable div. I also tried using word-break: break-all which seemed to work but then the text gets a little messed up.
Also on a side note, has anyone ever experienced an issue where they were unable to click between characters once the text was highlighted? This is kind of a weird issue to describe, and a tough one to track down apparently. What happens is I will type some text into the div, highlight it with my cursor, and then if I try to deselect the text by clicking in between characters, it will not work. I will have to click a line that is currently not highlighted or outside of the element entirely to deselect any highlighted text.
I originally thought maybe it was a content editable issue, but it seems to be working fine in the code pen I linked, so now I am not sure what it is.
Thanks in advance for the help!
You have to use word-break for solving your issue.Modify your css like following
body
{
background-color: black;
}
.text-box
{
background-color: white;
color: black;
height: 200px;
width:150px;
margin: auto;
white-space: pre-wrap;
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: pre-wrap; /* css-3 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
word-break: break-word;
white-space: normal;
}
This solves your problem.Here is the working pen pen
Please reffer this ans for more info

Force all lines HTML content (with embedded element) to fill width of container

I have a piece of HTML content such as:
<span class="wrappable"><i>(03/10/2016) Author Name</i> LongContentWithoutLineBreakLongContentWithoutLineBreakLongContentWithoutLineBreakLongContentWithoutLineBreakLongContentWithoutLineBreakLongContentWithoutLineBreakLongContentWithoutLineBreakLongContentWithoutLineBreakLongContentWithoutLineBreakLongContentWithoutLineBreakLongContentWithoutLineBreakLongContentWithoutLineBreakLongContentWithoutLineBreak</span>
The "wrappable" css class is defined as:
.wrappable
{
overflow-wrap: break-word !important;
word-wrap: break-word !important;
white-space: normal !important;
display: inline !important;
}
Please refer to https://jsfiddle.net/dn9tt26e/ run the fiddle.
At least in Firefox version 45.0.1, this produces an output that breaks on the first line without the line filling the width of its container. For pure text content, there is no such issue, but as soon as I add an embedded HTML element, seems the issue appears.
How do I ensure all lines (excepts perhaps the last) fill the full width of the container without breaking prematurely?
Some pictures of what I see in my browser:
Suggested solution using break-word:all https://jsfiddle.net/4bu8ctt4/ in Firefox:
Local page on my machine in Firefox:
Local page in IE 11 (this one does not wrap the second line at all)
You have basically 2 words combined with break-word, which means it'll put any long word in new line. Try with word-break: break-all;
https://jsfiddle.net/4bu8ctt4/
Im sorry if i misunderstood you, but maybe this helps?
add property to your class
word-wrap: break-word;
like this
.wrappable
{
overflow-wrap: break-word !important;
word-wrap: break-word !important;
white-space: normal !important;
display: inline !important;
word-wrap: break-word;
}
source:
http://www.w3schools.com/cssref/css3_pr_word-wrap.asp

Responsive pre tag

I simply want to show terminal output on a Webpage. Atm I'm using a pre tag to do that with pre { white-space: pre-wrap; } as you can see upon http://irc.dabase.com/.
My problem is that when I rotate my iPhone6 IOS device, it often doesn't reformat properly. Why is this? Can you offer some good CSS rules to make this use case of showing terminal output on a Webpage better?
pre {
white-space: pre-wrap;
word-wrap: break-word;
text-align: justify;
}
Here are the rules you need explained step by step:
Select all pre elements (set this to pre#yourID or pre.yourClass to select a specific pre)
pre {
Allow pre to wrap at word breaks and line breaks. Unlike pre-line, pre-wrap will not modify your terminal output at all. pre-line will modify your terminal output by condensing whitespace into one whitespace which could make finding exact phrases difficult or mess with whitespace column formatting! See here
white-space: pre-wrap;
Make sure that words that go past the end of the element break off instead of being hidden (like links for examples)
word-wrap: break-word;
This part is optional Justify the text so that it fully fills the line. Spaces become wider but their number is not increased.
text-align: justify;
}
Optionally, this rule can be fit into a media-query so that it only applies in the mobile version. But I believe there is no harm in applying this rule to all screen sizes by simply omitting a media-query.
In the event that the wider version of your iphone makes your pre rule stop working, you should check to see if there isn't already a media-query in place that is applying a rule to the pre when the screen reaches a certain size.
You can also try intentionally creating a media-query for the wider version, which may re-initialize the styles if there is some kind of bug going on.
For example:
Include rule that applies to smallest possible version
Rule A:
pre {
white-space: pre-wrap;
word-wrap: break-word;
text-align: justify;
}
Then in addition to rule A include another rule to re-initialize styles at landscape orientation
Rule B:
#media all and (orientation:landscape)
pre {
white-space: pre-wrap;
word-wrap: break-word;
text-align: justify;
}
}
You can try this to achieve -
pre {
white-space: pre-line;
word-wrap: break-word;
}
pre {
white-space: pre-line;
word-wrap: break-word;
text-align: justify;
}
You Can Try It Once
This worked nicely for me when I had pre tag inside of a table and code below made pre tag stay responsive to the table column width. Credits to: https://techstacker.com/responsive-pre-tags-css/
pre {
white-space: pre-wrap;
word-break: break-all;
}

Issue with text wrap on IE10 with brackets

I have a link in a navigation menu that doesn't wrap properly on IE10.
When there is a conditional plural using brackets, IE10 cut off the word into 2 separated lines. I am expecting the whole word "link(s)" to go to the next line if there is not enough space, like Chrome is doing.
It's supposed to look like this:
Hello worldddd
link(s)
I tried to use the different word-wrap and word-break attribute but it doesn't fix it. If I use white-space: nowrap, the word doesn't go to the next line. I don't want to force the word to go to the next line for all browsers.
Do you know what I can do to fix this IE issue?
Let's say you have a text like this:
<p>this is a longer <span class="nowrap">test(s)</span></p>
Then all you need to do is apply following CSS:
p {
word-break: break-word;
}
#media all and (-ms-high-contrast:none)
{
/*target IE10*/
.nowrap {
white-space: pre;
}
/*target IE11*/
*::-ms-backdrop, .nowrap {
white-space: pre;
}
}
working jsfiddle - you can resize HTML input area to see the difference

CSS word wrapping causes huge spaces between words

Hi! When the window is resized, the text automatically wraps to fit its container nicely. For this, I'm using this CSS code:
article {
overflow: auto;
word-wrap: break-word;
}
Though it seems, that this has no effect at all. When I remove this piece of code, the behavior doesn't change: the text is still wrapped near the end of the line.
I'm complaining about the huge gaps between words. I've observed a few webpages where no extra code is used for this and it still works nicely. Can you please help me get rid of the space? Thank you!
I agree that the text-align: justify has been inherited from the parent html tags.
You could also try modifying the CSS as follows:
article {
overflow: auto;
word-wrap: break-word;
text-align: start;
}
As mentioned in the comments article seems to be inheriting text-align: justify;. Here's a way to fix the alignment:
http://jsfiddle.net/awesome/zs394/2/
article, .unjust {
/* regular */
text-align: left;
/* super strength */
text-align: left !important;
}