Since the last couple of things I’d like to see in CSS got thoroughly shot down I figured I’d throw out another. One thing that bothers me to no end is that % is always a percentage of the width, even if you are dealing with the height. It would be nice to be able to specify by placing h for height to the right of the %
padding-top: 20%h;
%w would be permitted for clarity, but merely an alias to % by itself. Thoughts?
I dunno about the syntax you propose but yes it generally is a pain in the bum. I think some cool things like float:bottom could be achieved if this syntax were to arise.
I’m not sure I’d use this all that much but I like the idea. For those of us who have been in the situation where this would be useful, I’ll say that I wish it was available.
As I said though, the syntax looks a bit odd. No counter-proposal for syntax though so carry on .
It’s essentially already here - a bit buggy, but here. It’s vw, vh, vmin and vmax. While the linked article talks about typography, it works on all elements (I recently used it on a background image to give me a responsive sizing logo)
vw = % of the viewport width
vh = % of the viewport height
vmin = % of whatever is smaller between the viewport height and the viewport width
vmax = % of whatever is larger between the viewport height and the viewport width.
Granted it’s limited because it’s based on the viewport and not the container it’s in, but it is there. You just have to think a different way.
As Ryan points out, that’s not really what I’m asking for. Percentages are far more likely to be accorded to the current element, or parent (depending on context) than the viewport. What you suggest is so useless that well planned em unit use would be far more effective.
Ah, there you go. See, just basic musing. I haven’t studied CSS 4 selectors yet, it will be 5 years before enough browsers support them to make them feasible.
Understandable. It’s technically been removed off of the official version of the draft, but those things change so often.
I actually did read through the ENTIRE CSS3/4 specification and highlighted the coolest features I found. If you are curious about some of the cool things coming up (some already sorta here like flexbox) then read this.