Apply Ellipsis When Label Text Is Overflow

How to use text-overflow: ellipsis with a label element?

To hide overflow in an element, the element needs to be block-level. But you probably don't want an inline label to be block-level because that could cause other issues. So just make it inline-block:

label#cats {
white-space: nowrap;
width: 30px;
overflow: hidden;
text-overflow: ellipsis;
border: 1px solid #000000;
display: inline-block;
}

jsFiddle: http://jsfiddle.net/rdg221bx/1/

Ellipsis is not working properly for label

Move the ellipsis rules to the li and set the labels to display:inline;

ul {  min-width: 200px;  margin: 0;  border-radius: 0;  max-height: 270px;  max-width: 200px;  background: red;}
label { display: inline;}
li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
<html><ul class="dropdown-menu main ">  <li>    <a href="#">Select All</a>  </li>  <li>    <a href="#">Select None</a>  </li>  <li>    <label>my numbers</label>  </li>  <div>    <li>      <input type="checkbox">      <label class="">one</label>    </li>    <li>      <input type="checkbox">      <label class="">onHow to use text-overflow: ellipsis with a label element? Ellipsis is not working properly for label CSS text-overflow on label apply ellipsis when label text is overfloHow to use text-overflow: ellipsis with a label element? Ellipsis is not working properly for label CSS text-overflow on label apply ellipsis when label text is overfloee</label>    </li>    <li>      <input type="checkbox">      <label class="">twoooooooooooo0000oooooooo</label>    </li>
</div>
<button>cancel</button> <button>Apply</button></ul>
</html>

CSS text-overflow on label

label or span are inline by default. You cannot set width on inline elements.
So make label inline-block

/// markup

<input type="checkbox"/> <label style="display: inline-block; width: 60px; overflow: hidden">Sample text sample text</label>

apply ellipsis when label text is overflow

New CSS:

#media-played,#remarks {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display:block;
}

#player-play, #player-stop
{
display: inline-block;
width: 48px;
height: 48px;
}
#player-play
{
background-image: url('../images/play.png');
}
#player-stop
{
background-image: url('../images/stop.png');
}

jsFiddle:http://jsfiddle.net/dTffH/

Flutter - Wrap text on overflow, like insert ellipsis or fade

You should wrap your Container in a Flexible to let your Row know that it's ok for the Container to be narrower than its intrinsic width. Expanded will also work.

screenshot

Flexible(
child: new Container(
padding: new EdgeInsets.only(right: 13.0),
child: new Text(
'Text largHow to use text-overflow: ellipsis with a label element? Ellipsis is not working properly for label CSS text-overflow on label apply ellipsis when label text is overfloHow to use text-overflow: ellipsis with a label element? Ellipsis is not working properly for label CSS text-overflow on label apply ellipsis when label text is overfloeeeeeee',
overflow: TextOverflow.ellipsis,
style: new TextStyle(
fontSize: 13.0,
fontFamily: 'Roboto',
color: new Color(0xFF212121),
fontWeight: FontWeight.bold,
),
),
),
),

Button with a really long label with text-overflow ellipsis has a max-width of 700px but should shrink if the viewport gets smaller, doesn't got it

The answer to my question was to add overflow-x: hidden to the box. This answer was given to me by someone else, here is their demo:

https://codesandbox.io/s/mui-testing-forked-qbcnn

And here is the fixed styling pasted again:

const useStyles = makeStyles((theme) => ({
box: {
flex: "1 1 100%",
display: "flex",
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
overflowX: "hidden" // <--- This is new
// maxWidth: "100%",
// width: "100%"
},
button: {
width: "100%",
maxWidth: 700,

"& .MuiButton-label": {
textOverflow: "ellipsis",
whiteSpace: "nowrap",
overflow: "hidden",
textAlign: "left",
display: "block"
}
}
}));

Button with ellipsis on a label, sized by parent

Button width is based on its content or parent element. You need to modify some styles to achieve ellipsis content:

<PrimaryButton
...
styles={{
textContainer: {
overflow: 'hidden',
},
label: {
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
}
}}
/>

Codepen working example.

Useful links:

MDN Text Overflow

Fluent UI Styling Guide

Setting ellipsis on text from a flex container

The ellipsis need to be set on the text element, not on the container:

.target {  display: flex;  align-items: center;  width: 300px;  height: 50px;  border: solid 1px red;  white-space: nowrap;}
span { overflow: hidden; text-overflow: ellipsis;}
<label class="target">  <span>Text here is very very long that it might get truncate if this box get resized too small</span></label>


Related Topics



Leave a reply



Submit