Best illustrated with a simple code example:
.container {
width: 100px;
background: #f00;
white-space: nowrap;
font-size: 30px;
height: 20px;
overflow-x: visible;
overflow-y: hidden;
}
<div class="container">gggg gggg gggg gggg</div>
I am using properties:
overflow-x: visible;
overflow-y: hidden;
and hoping that the text that goes horizontally outside of the container will be hidden, but the text/characters that span vertically will remain visible.
To clarify the use case:
I want to restrict container width and height. The overflowing text needs to be cut-off.
This can be done with simple overflow: hidden;
and text-wrap: word-wrap;
. The problem is that certain font characters vertically overflow outside of the line-height/container height, e.g.
Notice the "g" and "y" letters.
Therefore, my plan is no set white-space: nowrap
and somehow force to allow only vertical overflow visibility. This causes two problems:
- It appears that I cannot have different visibility values for overflow-x/overflow-y.
- I cannot use
text-wrap
withwhite-space: nowrap