So I have the following Fiddle that has set an ellipsis in a text into two lines. Then I want to have a 'More' link inline with the text.
http://jsfiddle.net/csYjC/2876/
So if our text has more than two lines, it should look like this:
That's correct. However:
That's not correct (should be inline with the text).
Code is like follows:
<div class="text">
<div>Lorem ipsum dolor sit amet, Lorem Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, Lorem Lorem i</div>
<a href="#">More</a>
</div>
And the css:
.text{
display: inline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
line-height: 24px; /* fallback */
max-height: 48px; /* fallback */
-webkit-line-clamp: 2; /* number of lines to show */
-webkit-box-orient: vertical;
}
.text a {
position: absolute;
}
I guess must be easy... Thank you in advance.
Draw a simple rectangle. Your choice of height and width , of the rectangle, will dictate the size and shape of the ellipse. The border-radius refers to the curvature at the corners of the shape; it should be set to a very high value (50% to 100%). An ellipse has been created!
A text-overflow property in CSS is used to specify that some text has overflown and hidden from view. The white-space property must be set to nowrap and the overflow property must be set to hidden. The overflowing content can be clipped, display an ellipsis ('…'), or display a custom string.
Well, here's a kind of a funny solution with pure CSS using pseudo elements. http://jsfiddle.net/j8ekzvLq/
.text {
display: inline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
line-height: 24px; /* fallback */
max-height: 48px; /* fallback */
-webkit-line-clamp: 2; /* number of lines to show */
-webkit-box-orient: vertical;
position: relative;
padding-bottom: 24px;
}
.text::before {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 24px;
background-color: #fff;
z-index: 1;
}
.text div {
background-color: #fff;
display: inline;
position: relative;
}
.text div::after {
content: "";
background-color: #fff;
position: absolute;
bottom: -24px;
left: 0;
width: 100%;
height: 24px;
z-index: 2;
}
.text a::before {
content: "More";
position: absolute;
bottom: 0;
left: 0;
text-decoration: underline;
z-index: 1;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With