.textarea {
display: block;
width: 400px;
margin-bottom: 20px;
border: 1px solid black;
overflow: hidden;
white-space: nowrap;
}
.clip {
text-overflow: clip;
}
.ellipsis {
text-overflow: ellipsis;
}
<div class="textarea clip">
<p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five </p>
</div>
<div class="textarea ellipsis">
<p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
</div>
Here after setting the value text-overflow:ellipsis ,I am not getting three dot(...) which should come ,if there is more text given that width is not so much enough to accommodate all the text.
I have tried with different width values but no required result is coming.
Because overflow and text-overflow in not an inherited property and you have applied it on .textarea so no effect on the <p> will take place.
You can apply white-space:nowrap to the .textarea as it is an inherited css property.
So apply overflow:hidden and text-overflow to the <p> instead of .textarea..
Also you have a typo error in your above code...textarea will be .textarea because its a class not a tag
Stack Snippet
.textarea {
display: block;
width: 400px;
margin-bottom: 20px;
border: 1px solid black;
white-space: nowrap;
}
.clip p {
text-overflow: clip;
overflow: hidden;
}
.ellipsis p {
text-overflow: ellipsis;
overflow: hidden;
}
<div class="textarea clip">
<p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five </p>
</div>
<div class="textarea ellipsis">
<p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
</div>
Related
I don't need to expand/collapse the text, read more will be a hyperlink. I only need static visual properties.
In code snippet below (optimally, look at it in full page), in the first paragraph, it is how it looks like when there is overflow.
On second paragraph, there is no overflow and it looks fine.
On third paragraph, it is how I want it to look like when there is overflow. I want only the card_def to truncate, and read more text to be at the end of third line.
.card_short {
max-height: 65px;
max-width: 603px;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
.card_def {
font-size: 16px;
display: inline;
overflow: hidden;
}
.card_readmore {
font-size: 16px;
display: inline;
color: #0057b3;
}
<div>This is how it looks when there is an overflow, I don't want this:</div>
<div class="card_short">
<h3 class="card_def">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</h3>
<h3 class="card_readmore">Read more</h3>
</div>
<br><br>
<div>When there isn't overflow, this paragraph is fine:</div>
<div class="card_short">
<h3 class="card_def">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum... There is no overflow here.</h3>
<h3 class="card_readmore">Read more</h3>
</div>
<br><br>
<div>I want the first paragraph to look like this:</div>
<div class="card_short">
<h3 class="card_def">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type s...</h3>
<h3 class="card_readmore">Read more</h3>
</div>
Target the first .card_short and give this element a max-height: 100%;.
.card {
position: relative;
max-width: 603px;
}
.card_short {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
.card_def {
font-size: 16px;
display: inline;
overflow: hidden;
}
.card_readmore {
font-size: 16px;
display: inline;
color: #0057b3;
position: absolute;
right: 12px;
bottom: -16px;
background-color: white;
}
.d-none {
display: none;
}
<div class="card">
<div>This is how it looks when there is an overflow, I don't want this:</div>
<div class="card_short">
<h3 class="card_def">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.</h3>
<h3 class="card_readmore" style="bottom: 32px;">...Read more</h3>
</div>
<br><br>
</div>
<div class="card">
<div>When there isn't overflow, this paragraph is fine:</div>
<div class="card_short">
<h3 class="card_def">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum... There is no overflow here.</h3>
<h3 class="card_readmore d-none">...Read more</h3>
<!-- no overflow content, no read more -->
</div>
<br><br>
</div>
<div class="card">
<div>I want the first paragraph to look like this:</div>
<div class="card_short">
<h3 class="card_def">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type s</h3>
<h3 class="card_readmore">...Read more</h3>
</div>
</div>
I have 3 divs with anchor tags nested in them. I am trying to reposition them so that they are inline side by side evenly spaced from each other. No matter what I try they just end up overlaying on top each other.
Here is my CSS code
.links {
width: 35%;
text-align: center;
border: solid 1px;
background-color: #02b316;
margin: 5px;
position: absolute;
}
.absolute {
text-decoration: none;
color: white;
font-size: 11px;
}
.link-container {
padding-left: 5px;
padding-right: 5px;
}
h4 {
font-size: 18px;
margin: 10px;
}
p {
font-size: 14px;
}
Here is my HTML
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
You want to use a flex-box so it's responsive. Here is an example. :)
.container {
display: flex;
flex-wrap: wrap;
}
.links {
flex: 1;
text-align: center;
border: solid 1px;
background-color: #02b316;
margin: 5px;
}
.absolute {
text-decoration: none;
color: white;
font-size: 11px;
}
.link-container {
padding-left: 5px;
padding-right: 5px;
}
h4 {
font-size: 18px;
margin: 10px;
}
p {
font-size: 14px;
}
<div class="container">
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
</div>
<style>
.container {
padding: 10px
}
.content1 {
margin-left: 0px;
height: 90px;
width: 24%
background: #ddd;
}
.content2 {
background: #3ce223;
height: 90px;
width: 24%;
float: center; /*if that doesn't work than replace it with this: margin-left: 500px; */
}
.content3 {
background: #3dn210o;
height: 90px;
width: 24%;
float: right; /*if that doesn't work than replace it with this: margin-left: 1000px; or at least until it is right of the screen */
}
</style>
<div class="container">
<div class="content1">
</div>
<div class="content2">
</div>
<div class="content3">
</div>
</div>
If none of that works please comment and I will address the issue
Try this out.
.container {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.links {
width: 35%;
text-align: center;
border: solid 1px;
background-color: #02b316;
margin: 5px;
}
.absolute {
text-decoration: none;
color: white;
font-size: 11px;
}
.link-container {
padding-left: 5px;
padding-right: 5px;
}
h4 {
font-size: 18px;
margin: 10px;
}
p {
font-size: 14px;
}
<div class="container">
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
</div>
The div element is displayed as a block element by default, display: block in code. This has to be changed.
The given position: absolute makes all the elements appear at the same spot.
On top of this the blocks including their added margins and paddings do not fit on the whole width of the page. This also needs adjustments.
Change your css .links and .link-container declarations:
.links {
width: 30%;
text-align: center;
border: solid 1px;
background-color: #02b316;
margin: 1%;
position: relative;
display: inline-block;
}
.link-container {
padding-left: 1%;
padding-right: 1%;
}
This question already has an answer here:
How to create uneven rounded sides on a div?
(1 answer)
Closed 3 years ago.
I tried like this but it's not right solution. Any solutions for this issue please.
.shape {
width: 200px;
height: 100px;
position:absolute;
top: 0;
right: 0;
background: red;
-moz-border-radius: 0px 0px 20px 110px;
-webkit-border-radius: 0px 0px 20px 110px;
border-radius: 0px 0px 20px 110px;
}
<div class="shape"></div>
I have added a :pseudo element and postioned it
.bg-shape {
position: relative;
overflow: hidden;
padding: 50px;
}
.bg-shape:after {
content: '';
position: absolute;
width: 600px;
height: 600px;
background: red;
border-radius: 50%;
top: 0;
right: 0;
z-index: -1;
top: -60%; /* change value as required */
right: -20%; /* change value as required */
}
<div class="bg-shape">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
</p>
</div>
Does anyone know how to use the following css trick with inline-blocks?
.text {
display: block;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
I have couple of text tags (h2 & h3) on the same line and even if I change the display: block to inline-block, it still messes up the layout.
Has anyone done anything similar?
EDIT: I only want to concatenate the h2 (first element), not the h3 tag content.
try this
p{
display: inline-block;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<p class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
</p>
Try to use line-height for class text with display:inline-block
.text{
display: inline-block;
/* adjust line height for class text*/
line-height: 25px;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<h2 class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
</h2>
<h3 class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
</h3>
.text {
display: inline-block;
line-height:20px;
width: 200px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<h2 class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy.
</h2>
<h3 class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy.
</h3>
I need to use the html <img> tag as a background image for a <div>. I will then be placing a <p> of content over this. I've tried this but cant seem to get them to display correctly. I've used position relative, margin with negative values.
Any suggestions or point me in the right direction would be appreciated.
<div>
<img src="http://www.shiaupload.ir/images/77810787432153420049.png" />
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book
</p>
</div>
To make an almost perfectly duplicate of the features used for background-image, we've to consider the features of the img include:
It doesn't have any pointer events.
It's rendered at least one layer below the div.
The result would be something like this:
div {
display: inline-block;
overflow: hidden;
position: relative;
width: 100%;
}
img {
pointer-events: none;
position: absolute;
width: 100%;
height: 100%;
z-index: -1;
}
p {
padding: 25px;
}
<div>
<img src="http://via.placeholder.com/720x480/ddd/007" />
<p>
Lorem Ipsum is simply dummy text of the printing and
typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the 1500s, when an unknown
printer took a galley of type and scrambled it to make a type
specimen book
</p>
</div>
You might modify the width and height to your needs.
In the future this may be possible with the new css element() function:
background-image: element(img_element_id)
https://developer.mozilla.org/en-US/docs/Web/CSS/element