This question already has answers here:
html/CSS Ellipsis
(2 answers)
Applying an ellipsis to multiline text [duplicate]
(23 answers)
Closed 6 years ago.
How can I show three dots(...) in a text like this?
Add all these.
To make in single line.
{
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
width:100px; /* some width */
}
To do in multi line which actually you asked.
#content {
overflow: hidden;
width:100px;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
working fiddle:
https://jsfiddle.net/mishrarajesh/676jc7sa/
Please note that this multiline code is supported only in web-kit browsers for now.
Related
This question already has answers here:
How to turn off word wrapping in HTML?
(6 answers)
Closed 2 years ago.
Codepen
I'm trying to avoid word-breaks, in my .threadTitle, by using display: inline-block. This works, however when adding a hyphen inbetween two letters will it will cause a break anyways.
Neither word-break: keep-all nor display: inline-block has the desired effect.
.threadTitle {
position: relative;
display: inline-block;
word-break: keep-all;
flex: 1 1 0;
overflow: hidden;
}
This is mostly a Unicode problem, not an HTML one. You need to use non-breaking hyphens (‑, U+2011) instead of a normal hyphens:
<p>This-is-a-really-long-sentence-separated-by-breaking-hyphens-that-will-be-split-among-various-lines.</p>
<p>This‑is‑a‑really‑long‑sentence‑separated‑by‑non‑breaking‑hyphens‑that‑won't‑be‑split‑among‑various‑lines.</p>
This is useful for making sure hyphenated words are never broken between two lines.
If you don't want wrapping at all, use white-space: nowrap;, as Ori Drori's answer suggests.
p {
white-space: nowrap;
}
<p>This is a really long sentence separated by breaking (normal) spaces that won't be split among various lines because <code>white-space: nowrap;</code> is being used.</p>
use white-space: nowrap; to prevent text wrapping:
.threadTitle {
position: relative;
display: inline-block;
white-space: nowrap;
flex: 1 1 0;
overflow: hidden;
}
<h1 class="threadTitle">Thread-Titleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee</h1>
This question already has answers here:
Can CSS force a line break after each word in an element?
(12 answers)
converting white space into line break
(2 answers)
Closed 3 years ago.
I have a word 'Mon 24'.
What is the best approach to break it into different line as in
Mon
24
through css?
I have tried using word-break: break-all but no luck.
https://codepen.io/bbk_khadka/pen/zbVLEp
Set the maximum width to be 3 characters wide
.text {
max-width: 3ch;
}
https://codepen.io/anon/pen/jJjpKV
word-break: break-all will not support all browsers to wrap down. My suggestion to use max-width and table-caption to wrap.
.text {
display: block;
max-width: 40px;
}
<div class='text'>Mon 24<div>
.text {
display: table-caption;
}
Let the element behave like a <caption> element.
<div class='text'>Mon 24<div>
This question already has answers here:
How can I do text-overflow: ellipsis on two lines?
(5 answers)
Closed 6 years ago.
In the jsfiddle link you can find what I tried out, however when the text goes over two lines, I do not see the ellipsis anymore. Can somebody help me out. Im new to CSS, and what to solve this problem using CSS/SASS only.
.exciting-text {
display: block;
text-overflow: ellipsis;
word-wrap: break-word;
overflow: hidden;
max-height: 2em;
line-height: 1em;
}
.exciting-text::after {
content: "...";
color: red;
}
<p class="exciting-text">Contributing to MDN is easy and fun.Just hit the edit button to add new live samples, or improve existing samplesdfsfssfddcdxcxdsdzxfsfdsadasdaddsadsadsadsadsadasdasfds.</p>
In current example your problem is max-height. Get rid of it and your pseudo ellipsis will be visible at all times.
I want to wrap my long article in to three to four lines and a more button below. Currently, i am using the below css code.
.truncate {
width: auto;
text-align: justify;
word-break: keep-all;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
The above css class does what i want . However, it shortens the artcile to a single line code code only. I tried everything possible to make it in to three or four and half lines and din't succeed. I thought of adding a height property and didn't change. please how do i control the number of lines. ? Any help would be appreciated.
Update
Just like on SO here . A question title, and just two lines from the post. Please how do i achieve that ?
You can use -webkit-line-clamp: 2; -webkit-box-orient: vertical;. But it's only for webkit browsers.
http://jsfiddle.net/tv2mfxe5/1/
.truncate {
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
And if this doesn't work for you. I would recommend using a jQuery plugin, dot dot dot
This question already has answers here:
How do I disable the resizable property of a textarea?
(20 answers)
Closed 8 years ago.
How to disable the grabber in the <textarea>?
I mean that triangle thing which appears in the right-bottom corner of the <textarea>.
Just use resize: none
textarea {
resize: none;
}
You can also decide to resize your textareas only horizontal or vertical, this way:
textarea { resize: vertical; }
textarea { resize: horizontal; }
Finally,
resize: both enables the resize grabber.
<textarea style="resize:none" name="name" cols="num" rows="num"></textarea>
Just an example
example of textarea for disable the resize option
<textarea CLASS="foo"></textarea>
<style>
textarea.foo
{
resize:none;
}
</style>