I want to create an angled text flow where the width of a text line is a known value --w. What I have so far is the code below:
* { margin: 0 }
html, body { display: grid }
body {
--w: min(35em, 65vw);
--f: 1/ 8;
background: linear-gradient(90deg, transparent var(--w), pink 0);
font: 1em ubuntu, sans-serif
}
.outer-wrapper {
width: min-content;
box-shadow: 0 0 0 2px red;
background: lemonchiffon
}
span::before, span::after {
--i: 0;
--j: calc(1 - var(--i));
--g:
linear-gradient(to right bottom,
hsla(50, 50%, 50%, var(--j)) 50%,
hsla(50, 50%, 50%, var(--i)) 0);
float: left;
height: 100%;
aspect-ratio: var(--f);
background: var(--g);
shape-outside: var(--g);
content: ''
}
span::after {
--i: 1;
float: right
}
.inner-wrapper {
width: var(--w);
box-shadow: inset 0 0 0 2px blue
}
<div class="outer-wrapper">
<span aria-hidden="true"></span>
<div class="inner-wrapper">
<p>Gingerbread macaroon cake topping wafer cake dessert. Lemon drops cheesecake lemon drops lollipop biscuit tart. Chupa chups bonbon dragée tart pie. Oat cake cupcake bear claw pie ice cream ice cream. Jelly beans ice cream icing halvah cotton candy. Tiramisu dragée macaroon chocolate bar chocolate cake. Sweet roll wafer candy gummies donut wafer liquorice sugar plum. Icing gummies chocolate cake gummies caramels sweet roll. Tootsie roll jelly beans jelly chocolate jelly beans pie. Halvah lollipop lemon drops shortbread bonbon. Jelly biscuit bear claw cotton candy cotton candy chocolate bar soufflé donut lollipop. Fruitcake lemon drops marshmallow sugar plum cheesecake gingerbread. Sugar plum chupa chups candy canes jelly-o powder liquorice icing.</p>
<p>Gingerbread macaroon cake topping wafer cake dessert. Lemon drops cheesecake lemon drops lollipop biscuit tart. Chupa chups bonbon dragée tart pie. Oat cake cupcake bear claw pie ice cream ice cream. Jelly beans ice cream icing halvah cotton candy. Tiramisu dragée macaroon chocolate bar chocolate cake. Sweet roll wafer candy gummies donut wafer liquorice sugar plum. Icing gummies chocolate cake gummies caramels sweet roll. Tootsie roll jelly beans jelly chocolate jelly beans pie. Halvah lollipop lemon drops shortbread bonbon. Jelly biscuit bear claw cotton candy cotton candy chocolate bar soufflé donut lollipop. Fruitcake lemon drops marshmallow sugar plum cheesecake gingerbread. Sugar plum chupa chups candy canes jelly-o powder liquorice icing.</p>
<p>Gingerbread macaroon cake topping wafer cake dessert. Lemon drops cheesecake lemon drops lollipop biscuit tart. Chupa chups bonbon dragée tart pie. Oat cake cupcake bear claw pie ice cream ice cream. Jelly beans ice cream icing halvah cotton candy. Tiramisu dragée macaroon chocolate bar chocolate cake. Sweet roll wafer candy gummies donut wafer liquorice sugar plum. Icing gummies chocolate cake gummies caramels sweet roll. Tootsie roll jelly beans jelly chocolate jelly beans pie. Halvah lollipop lemon drops shortbread bonbon. Jelly biscuit bear claw cotton candy cotton candy chocolate bar soufflé donut lollipop. Fruitcake lemon drops marshmallow sugar plum cheesecake gingerbread. Sugar plum chupa chups candy canes jelly-o powder liquorice icing.</p>
</div>
</div>
The problem is that I would like the floated pseudos on the sides to add to the --w width and make the .outer-wrapper wider by the width of one because otherwise, text overflows outside the red outline box.
And I have no idea how to do that with CSS. I know it's possible with JS, I have a working version were I read the px-valued height, store it in a variable, update it on resize and compute all from there. But I'd really like to do it with just CSS.
Skewing the box is not a useful solution in this case.



It's not without its drawbacks and might not work for your specific use-case, but you could use a hidden copy of the content in a narrower container to determine the height you need, then use
height: 100%to give.outer-wrapperthe height it needs. Here's my code:The potential issues are:
.outer-wrapperto be a little too big, you could add one or two extra lines to cover yourself by giving.height-setter1 or 2 ems of bottom padding.visibility: hiddenis set)..outer-outer-wrapperis wider than the content displayed inside it. On my screen with your code this was fine, but in practice you might need some clever flex cropping or an.outer-outer-outer-wrapperwithoverflow: hiddenset to get around this.