-
Notifications
You must be signed in to change notification settings - Fork 718
[css-box] Suggestion: Add "of <property>" syntax for percentage values of padding and margin properties #6814
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
Comments
Assuming that the parent is the containing block, and that the desired property computes to a length, then #2864 already resolved to add an margin-top: calc(0.1 * inherit(height));
padding-left: calc(0.5 * inherit(padding-left));
padding-bottom: calc(0.3 * inherit(border-bottom-width)); But
I think it's fine, cycles already happen right now and they are handled in https://drafts.csswg.org/css-sizing-3/#cyclic-percentage-contribution |
@Loirooriol Thank You for the hint to #2864. I didn't know that an As I also thought once again about cycles, especially using expressions like Thank You once again for the link to [css-sizing-3]. |
You can't find any specification of Sebastian |
Seems important to note that, technically speaking, the containing block is just a rectangle. Yes, it's typically established by an element, and we can refer to the properties of that element. But for example, sometimes the containing block is established by the content area, and sometimes by the padding area. What should I'm also not sure if there are clear usecases for So, rather than a BTW, there are units for query containers https://drafts.csswg.org/css-contain-3/#container-query-length |
@Loirooriol Yes, the containing block is by definition a rectangle, and it can be the content box or padding box of an element, the viewport, or even the bounding box of two differnt padding boxes of inline elements. Therefore, if we were only interested in the demensions of that rectangle, it would be the best to have new measures for that. Maybe, it would be a good idea to name them Concerning the
So, The ability to refer to arbitrary properties of the containing block may be unnecessary or unwanted for some people but it opens up more flexibility for the author of stylesheets, and maybe some new ideas concerning the usage open up new ways for layouts or special designs which were not possible with CSS today Of course, having new measures for the containing block is a first step in that direction. |
What if you use |
Percentage values for
Can You please explain in more detail what the problem is that You are concerned about? |
They refer to the height of the containing block rectangle. Not to the computed value of the
#grid {
display: grid;
height: 100px;
grid-template-rows: 10px 90px;
}
#grid-item {
grid-row: 1;
height: 50% of height;
} Again, this should likely use the containing block rectangle. So just like |
Uh oh!
There was an error while loading. Please reload this page.
The CSS Box Model Level 3 and CSS Box Model Level 4 Specifications define the properties
margin-top
,margin-right
,margin-bottom
,margin-left
,margin
,padding-top
,padding-right
,padding-bottom
,padding-left
, andpadding
. They are all allowed to have percentage values. Currently, the percentage value always refers to thewidth
of the containing block. This can be an unwanted restriction. In particular,margin-top
,margin-bottom
,padding-top
, andpadding-bottom
represent vertical lengths, and the percentage values refer to horizontal lenghts. This can be irritating.I want to suggest a more universal approach:
Please add the syntax
of <property>
for percentage values of all the mentioned properties.<property>
can be any property name of the containing block which has a length value. It would bring much greater flexibility in relating percentages to property values for the end user of CSS. E.g. You can writeI hope that this change is technically possible, as I don't know whether it could result in an infinite loop of the underlying algorithms (e.g. an element refers to the height of an ancestor element which depends on the height of exactly that descendant element).
I propose to offer similar extensions for other properties which allow percentage values such as
font-size
as end users also want to relate the font size to the height or width of the parent element which is currently not possible. Of course, that it out of the scope of the CSS Box Model Specification.The text was updated successfully, but these errors were encountered: