i have an Content in an table cell. The content inside is always centered and in the middle. But when the cell is smaller than the Content i want to truncate the Text. But it doesn't work. The Cell has a fixed width and height, but when i truncate it, the cell is to big.
Have anyone an Idea? Or is it possible to use jQuery?
HTML/CSS
<table>
<tr>
<td><a href="">
<div class="ev orange">
<div class="ev_text">EURO VI NORM PRODUCT MODIFICATION, M1 LANE KEEPING ASSIST N2 & M2</div>
</div>
</a>
</td>
</tr>
</table>
.ev {
color: #000;
cursor: pointer;
transition: box-shadow 0.1s linear;
/* line-height: 28px; */
position: relative;
height: 51px;
display: table;
border-left: 1px solid black;
border-right: 1px solid black;
font-size: 8px;
width: 20px;
height: 20px;
}
.ev_text {
color: #000;
cursor: pointer;
transition: box-shadow 0.1s linear;
line-height: 17px;
position: relative;
max-height: 51px;
min-height: 51px;
overflow: hidden;
line-height: normal;
display: table-cell;
vertical-align: middle;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
Here's my fiddle:
http://jsfiddle.net/vnx0sb2L/1/
Edit html structure and css as below.
<div class="ev_text">
<p class="truncate">EURO VI NORM PRODUCT MODIFICATION, M1 LANE KEEPING ASSIST N2 M2</p>
</div>
// css
.truncate{
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
max-width: 51px;
max-height: 51px;
}
The reason of this problem is you have made a div as display: table-cell where ellipsis works with block level element.
You can remove overrride properties from .ev_text class.
Test like this :
<style>
.ev {
color: #000;
cursor: pointer;
transition: box-shadow 0.1s linear;
/* line-height: 28px; */
position: relative;
height: 51px;
/*display: table;*/
border-left: 1px solid black;
border-right: 1px solid black;
font-size: 8px;
width: 20px;
height: 20px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ev_text {
color: #000;
cursor: pointer;
transition: box-shadow 0.1s linear;
line-height: 17px;
position: relative;
max-height: 51px;
min-height: 51px;
overflow: hidden;
line-height: normal;
display: table-cell;
vertical-align: middle;
text-align: center;
}
</style>
<table>
<tr>
<td style='max-width:12px;height:auto;'>
<div class="ev orange">
<div class="ev_text">EURO VI NORM PRODUCT MODIFICATION, M1 LANE KEEPING ASSIST N2 & M2BLALALLALALALLALALLALALALA</div>
</div>
</td>
</tr>
</table>
The text overflow have to be in .ev no in .ev_text
EDIT :
Also remove in css display table
Related
and I'm trying to add a black container below my video and add the title and description inside that black container on hover, but the description in overlapping the black container how to l keep it inside the black container.
.previewContainer.small {
position: relative;
width: 230px;
height: 129px;
margin-right: 4px;
display: inline-flex;
transition: 0.5s ease;
overflow: hidden;
white-space: nowrap;
flex: 1 1 0px;
transition: transform 500ms;
}
.title{
display: none;
}
.previewContainer.small:focus-within,
.previewContainer.small:hover{
margin-left: 65px;
transform: translateY(-50%) translateX(-50%);
z-index: 1;
width: 230px;
height: 250px;
background-color: #141414;
border-radius: 5px;
}
.small:focus ~ .small,
.small:hover ~ .small {
transform: translateX(25%);
}
.previewContainer.small:focus,
.previewContainer.small:hover {
transform: scale(1.6);
z-index: 1;
}
.Play{
position: absolute;
width: 100%;
display: flex;
margin-left: 10px;
background-color: transparent;
font-size: 10px;
padding: 0px;
transition-duration: 1s;
}
.title{
position: absolute;
text-transform: capitalize;
width: 100%;
display: flex;
margin-left: 10px;
background-color: transparent;
font-size: 5px;
transition-duration: 1s;
}
.description{
position: absolute;
display: flex;
padding-top: 30px;
margin-left: 10px;
background-color: transparent;
text-decoration:none;
overflow: hidden;
color: white;
}
.title h6{
color:#fff !important;
font-weight: 300;
font-size: 14px;
}
.video-item {
position: relative;
max-width: 100%;
transition: transform 0.2s;
z-index: 1;
cursor: pointer;
border-radius: 4px;
object-fit: cover;
}
<div class="previewContainer">
<div class="previewContainer small">
<a href"">
<video class="mylist-img video-item" onmouseover="this.play()" onmouseout="this.pause();">
<source src="https://sgcholdings.co.za/Backend/media/sample-30s.mp4">
Your browser does not support the video tag.
</video>
<div class="title">
<h6>Video One</h6>
</div>
<div class="description">
<p class="">Loren ipsum dolor sit amet because there are two,
there is web version which works on hover with a small pop up then </p>
</div>
</a>
</div>
</div>
so l want to contain the description to be inside that black background that comes when l hover. can someone assist how to contain the paragraph tag not to overlap
You can update your CSS with following code
.description {
white-space: normal;
}
white-space:normal Sequences of white space are collapsed. Newline characters in the source are handled the same as other white space. Lines are broken as necessary to fill line boxes.
In the CSS for div of class description add this rule
.description{
word-wrap: break-word;
}
CSS word-wrap property is used to break the long words and wrap them onto the next line. This property is used to prevent overflow when an unbreakable string is too long to fit in the containing box.
.previewContainer.small {
position: relative;
width: 230px;
height: 129px;
margin-right: 4px;
display: inline-flex;
transition: 0.5s ease;
flex: 1 1 0px;
transition: transform 500ms;
}
.title{
display: none;
}
.previewContainer.small:focus-within,
.previewContainer.small:hover{
margin-left: 65px;
transform: translateY(-50%) translateX(-50%);
z-index: 1;
width: 230px;
height: 300px;
background-color: #141414;
border-radius: 5px;
word-wrap: break-word;
}
.small:focus ~ .small,
.small:hover ~ .small {
transform: translateX(25%);
}
.previewContainer.small:focus,
.previewContainer.small:hover {
transform: scale(1.6);
z-index: 1;
}
.Play{
position: absolute;
width: 100%;
display: flex;
margin-left: 10px;
background-color: transparent;
font-size: 10px;
padding: 0px;
transition-duration: 1s;
}
.title{
position: absolute;
text-transform: capitalize;
width: 100%;
display: flex;
margin-left: 10px;
background-color: transparent;
font-size: 5px;
transition-duration: 1s;
}
.description{
position: absolute;
display: flex;
padding-top: 30px;
margin-left: 10px;
background-color: transparent;
text-decoration:none;
overflow: hidden;
color: white;
word-wrap: break-word;
}
.title h6{
color:#fff !important;
font-weight: 300;
font-size: 14px;
}
.video-item {
position: relative;
max-width: 100%;
transition: transform 0.2s;
z-index: 1;
cursor: pointer;
border-radius: 4px;
object-fit: cover;
}
<div class="previewContainer">
<div class="previewContainer small">
<a href"">
<video class="mylist-img video-item" onmouseover="this.play()" onmouseout="this.pause();">
<source src="https://sgcholdings.co.za/Backend/media/sample-30s.mp4">
Your browser does not support the video tag.
</video>
<div class="title">
<h6>Video One</h6>
</div>
<div class="description">
<p class="">Loren ipsum dolor sit amet because there are two,
there is web version which works on hover with a small pop up then </p>
</div>
</a>
</div>
</div>
This question already has answers here:
CSS "and" and "or"
(9 answers)
Closed 2 years ago.
Suppose, I have a div with following css proprties among with other similar divs.
<div
style="
display: block;
width: 200px;
border-right: 1px solid rgb(237, 237, 236);
white-space: nowrap;
min-height: 32px;
cursor: default;
padding: 5px 8px 6px;
font-size: 14px;
overflow: hidden;
height: 32px;
"
>
howdie
</div>
I want to select div by 2 inline properties display: block; and white-space: nowrap;.
I know I can select the div by one property like display: block;:
div[style*="display: block;"]{
// div selected
}
But can't select the div by 2 properties:
div[style*="display: block; white-space: nowrap;"]{
// nothing get selected
}
How to select div (without js) by 2 inline properties which may not be sequential like display: block; and white-space: nowrap;?
Specify style*=[""] for each style like this:
div[style*="display: block;"][style*="white-space: nowrap;"]{
...
}
div[style*="display: block;"][style*="white-space: nowrap;"]{
color: red;
}
div[style*="display: block;"]{
color: green;
}
<div
style="
display: block;
width: 200px;
border-right: 1px solid rgb(237, 237, 236);
white-space: nowrap;
min-height: 32px;
cursor: default;
padding: 5px 8px 6px;
font-size: 14px;
overflow: hidden;
height: 32px;
"
>
howdie
</div>
<div
style="
display: block;
width: 200px;
border-right: 1px solid rgb(237, 237, 236);
min-height: 32px;
cursor: default;
padding: 5px 8px 6px;
font-size: 14px;
overflow: hidden;
height: 32px;
"
>
howdie
</div>
div[style*="display: block"][style*="white-space: nowrap"]{
color:red;
}
<div
style="
display: block;
width: 200px;
border-right: 1px solid rgb(237, 237, 236);
white-space: nowrap;
min-height: 32px;
cursor: default;
padding: 5px 8px 6px;
font-size: 14px;
overflow: hidden;
height: 32px;
"
>
howdie
</div>
I have got problem with word wrapping in div.
I am trying to make something like that:
Link, but i have got this: Link. This is my code:
#div-1 {
height: 28px;
width: 250px;
margin-top: 5px;
border: 1px solid rgb(200,200,200);
}
#span-1 {
font-size: 18px;
color: #0066FF;
line-height: 28px;
position: absolute;
}
<div id="div-1">
<span id="span-1"> SomeTextSomeTextSomeTextSomeTextSomeText </span>
</div>
Can you help me? Thanks.
You can use white-space in combination with overflow. And text-overflow if you like. See the example below.
#div-1 {
height: 28px;
width: 250px;
margin-top: 5px;
border: 1px solid rgb(200,200,200);
font-size: 18px;
color: #0066FF;
line-height: 28px;
/* Does the magic */
overflow :hidden;
white-space: nowrap;
text-overflow: ellipsis; /* Adds the ... */
}
<div id="div-1">
SomeTextSomeTextSomeTextSomeTextSomeText
</div>
Add overflow property to your div style:
#div-1 {
overflow: hidden;
}
Hope that helps.
Remove position: absolute from #span-1 and add overflow-x: hidden; for #div-1. You can also use text-overflow: ellipsis; which adds ... if the text overflows.
#div-1 {
height: 28px;
width: 250px;
margin-top: 5px;
border: 1px solid rgb(200,200,200);
overflow-x: hidden;
}
#span-1 {
font-size: 18px;
color: #0066FF;
line-height: 28px;
}
<div id="div-1">
<span id="span-1"> SomeTextSomeTextSomeTextSomeTextSomeText </span>
</div>
Try this
Make #div-1 position:relative and add overflow:hidden property.
CSS
#div-1 {
height: 28px;
width: 250px;
margin-top: 5px;
border: 1px solid rgb(200,200,200);
overflow:hidden;
position: relative;
}
#span-1 {
font-size: 18px;
color: #0066FF;
line-height: 28px;
position: absolute;
}
HTML
<div id="div-1">
<span id="span-1"> SomeTextSomeTextSomeTextSomeTextSomeText </span>
</div>
hope this helps..
#div-1 {
height: 28px;
width: 250px;
margin-top: 5px;
border: 1px solid rgb(200,200,200);
overflow:hidden;
}
#span-1 {
font-size: 18px;
color: #0066FF;
line-height: 28px;
}
<div id="div-1">
<span id="span-1"> SomeTextSomeTextSomeTextSomeTextSomeText </span>
</div>
Add this:
word-wrap: break-word;
Can someone tell me why I cannot use z-index to position this link above it's containing div's top border? Link to jfiddle here. Code below:
<div class="social_story twitter ellipsis" style="word-wrap: break-word;">
<a class="floating-icon" href="https://twitter.com/au_cadc" target=
"_blank"></a>
</div>
.social_story{
width: 100%;
height: 358px;
padding-bottom: 20px;
margin-top: 20px;
position: relative;
background-color: #eeeeee;
overflow: hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
border-top: 30px solid #dd550c;
}
.floating-icon {
position: absolute;
width: 42px;
height: 42px;
top: -15px;
left: 15px;
background-color: white;
border-radius: 25px;
-webkit-transition: all 250ms;
-moz-transition: all 250ms;
transition: all 250ms;
z-index:2;
}
Because you have overflow set to hidden on your .social_story container.
i creating a tab view using divs. when one of the tab is active, i want to hide the outer divs bottom border so that i see the tab is selected.
but right now i see outer div bottom border, which is not great as in the image.
desired output:
my div is laid as:
<div class='clsTabContainer'>
<div class='clsCurrentTab'>Dashboard</div>
<div class='clsTab'>Leads</div>
<div class='clsTab'>Internet</div>
<div class='clsTab'>Tasks</div>
</div>
.clsTabContainer {
BACKGROUND-COLOR: #FFFFFF;
PADDING-LEFT: 0px;
WIDTH: 100%;
PADDING-RIGHT: 0px;
WHITE-SPACE: nowrap;
HEIGHT: 35px;
OVERFLOW: hidden;
PADDING-TOP: 3px;
border-bottom: #D0D0D0 1px solid;
}
.clsTab {
OVERFLOW-X: visible;
OVERFLOW-Y: hidden;
BACKGROUND-COLOR: #F0F0F0;
DISPLAY: inline-block;
WHITE-SPACE: nowrap;
HEIGHT: 100%;
FONT-SIZE: 10pt;
VERTICAL-ALIGN: middle;
CURSOR: pointer;
padding: 5px 10px 10px 10px;
margin-left: -1px;
border-left: #D0D0D0 1px solid;
border-right: #D0D0D0 1px solid;
border-top: #D0D0D0 1px solid;
}
.clsCurrentTab {
OVERFLOW-X: visible;
OVERFLOW-Y: hidden;
BACKGROUND-COLOR: #FFFFFF;
DISPLAY: inline-block;
WHITE-SPACE: nowrap;
HEIGHT: 100%;
FONT-SIZE: 10pt;
VERTICAL-ALIGN: middle;
CURSOR: pointer;
padding: 5px 10px 10px 10px;
margin-left: -1px;
border-left: #D0D0D0 1px solid;
border-right: #D0D0D0 1px solid;
border-top: #82C600 1px solid;
color: #82C600;
}
how to avoid outer divs border bottom on the selected div so that i see the corresponding tab is really looks selected.?
Following are the changes in current css to achieve this:
.clsTab {
height:19px;
}
.clsCurrentTab {
height:20px;
}
.clsTab,.clsCurrentTab {
vertical-align: top;
}
Remove overflow:hidden from .clsTabContainer.
See DEMO here.