Skip to content

[css-inline] textBottom property #4582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
oleedd opened this issue Dec 11, 2019 · 18 comments
Open

[css-inline] textBottom property #4582

oleedd opened this issue Dec 11, 2019 · 18 comments
Labels
css-inline-3 Current Work

Comments

@oleedd
Copy link

oleedd commented Dec 11, 2019

When font-size is bigger than element height. Only one element (div) is used. Expected result:
image
Should work at any font-size.

@fantasai
Copy link
Collaborator

@oleedd Can you explain a bit more what the problem is you're trying to solve?

@fantasai fantasai changed the title [Request] [css-text] textBottom property [css-inline] textBottom property Mar 11, 2020
@oleedd
Copy link
Author

oleedd commented Mar 11, 2020

If font-size is bigger than element height, it looks so:
image
But the needed result is:
image
So there is no low-level control for text position.
No addition elements are used.

@oleedd
Copy link
Author

oleedd commented Apr 17, 2020

No, it doesn't if to change font-size:
image
The thing is to improve css which doesn't have properties for such simple things.

@AmeliaBR
Copy link
Contributor

If I understand correctly, you're looking for something like the box alignment properties, which are still not fully supported for regular paragraph text, but which would give a lot of control over how content is aligned within a container.

You can almost get what you want with

display: grid;
align-content: unsafe end;

The grid on the paragraph is there to force it to treat the child text content as a separate layout block and to increase support for the align-content option.

The align-content: end says to align the child content to the bottom of the container. unsafe says to do so even if it overflows at the top.

But that fits the end of the full height of the text line to the bottom of the container, including “descenders” on the letters. I can't think of a way to get the baseline to align exactly with the border bottom.

image

Could you give a larger example of a design that needs this type of overflow & alignment? Why is the paragraph constrained to a shorter height than the text? Why is the overflow needed at the top? How should it behave if there are multiple lines of text? Without knowing those things, we cannot discuss a general solution.

@oleedd
Copy link
Author

oleedd commented Apr 18, 2020

It is interesting but "descenders" don't touch the bottom line in my case (at any font-size). Why?
image
But anyway, the baseline is needed.

I can't think of a way to get the baseline to align exactly with the border bottom.

I know that css doesn't support this so it is about a new feature. It is more about possibilities of css.

A larger example:
image
So text doesn't affect the table and doesn't go under the baseline at any font-size. And it is the sense.
Maybe just to make vertical-align: baseline stronger in the standard because it is limited now. It would be cool.

@fantasai
Copy link
Collaborator

@oleedd Still don't entirely understand what you're trying to do at a higher level. Can you please post some real-world examples where this is needed to accomplish a particular desired layout? Diagramming isn't helping to understand the use case.

@oleedd
Copy link
Author

oleedd commented May 27, 2020

In the above "larger example", font-size is different for words (some have bigger font size than height of the bands, some - less) but the lines are static and all the text starts on the line (not under). By default, the text will go under the line but it is useless. So it is a real-word example.
vertical-align: baseline is too weak to control this.

@fantasai
Copy link
Collaborator

@oleedd Still don't understand. Can you maybe screenshot or photograph an example of an actual page layout that you're trying to achieve in CSS?

@oleedd
Copy link
Author

oleedd commented May 27, 2020

I don't have that.
At first it is about possibilities of CSS.

@fantasai
Copy link
Collaborator

@oleedd Well... our job is to make use cases possible, not to create technology as a theoretical exercise. So if there's no use case, it's not worth spending time to address.

@oleedd
Copy link
Author

oleedd commented May 28, 2020

It is just about to make vertical-align: baseline stronger, working for this. No need to create something new. Possible?

@SelenIT
Copy link
Collaborator

SelenIT commented May 28, 2020

It is just about to make vertical-align: baseline stronger

Unfortunately, not exactly. It would require significant revision of the way how CSS controls the vertical position of the glyphs (which might be rather counter-intuitive, I admit).

To some extent, for the single-line text, the example from the initial post seems to be achievable by setting the line-height to zero (to make both above-baseline and below-baseline parts of the text "stick out" from the container) and adding an inline-block placeholder pseudo-element to push the baseline down by the needed length (example).

That said. this issue shows another example of authors' common need to access and control the exact geometric position of the rendered text and is likely related to #4792.

@oleedd
Copy link
Author

oleedd commented May 28, 2020

@SelenIT
Your example stops to work after changing font-size.
image

@SelenIT
Copy link
Collaborator

SelenIT commented May 28, 2020

That's why I added "to some extent" :(. Unfortunately, this method has a limitation that the middle point of the glyphs can't be above the top edge of the container, i.e., it breaks when the container height is less than ascender - (ascender + descender)/2.

(Please also note that ascender and descender are abstract metrics of the font and don't necessarily match the actual size of the corresponding character parts.)

@oleedd
Copy link
Author

oleedd commented Jun 1, 2020

@fantasai @SelenIT

the middle point of the glyphs can't be above the top edge of the container

Why is this rule necessary?

@oleedd
Copy link
Author

oleedd commented Jun 7, 2020

If you don't know - then it is useless and need to remove it. And that will solve this and similar issues.

@oleedd
Copy link
Author

oleedd commented Nov 30, 2022

That said. this issue shows another example of authors' common need to access and control the exact geometric position of the rendered text and is likely related to #4792.

That issue was closed. Is there anything new in css to solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-inline-3 Current Work
Projects
None yet
Development

No branches or pull requests

4 participants