I'm struggling with a limited space to display text and I want to avoid line breaks, scrolling, or overflowing the parent div. My specific issue involves text within an anchor tag, so I created a sample component to illustrate my goal:
function Component () {
return (
<div style={{ width: 100, border: 'solid 1px black'}}>
<a style={{ overflow: 'hidden'}} href='#'>Please hide any text that would cross the parent divs border instead of line breaking to make it longer.</a>
</div>
)
}
ReactDOM.render(
<Component />,
mountNode
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<div id="container" style="padding: 24px"></div>
<script>
var mountNode = document.getElementById('container');
</script>
How can I efficiently hide excess text to maintain the anchor tag's content in just one line?