Comments (2)
Great idea! Could you detail for all the cases what would be the resulting code?
from postcss-utilities.
yeah, sure. It's tedious to list resulting code for all 16 possible combinations of [horizontal]
and [vertical]
. So, I'll write results for [horizontal]
and [vertical]
in separate. I think it would be enough to clarify the idea.
/* [horizontal] == left */
position: absolute;
left: 0;
/* [horizontal] == center */
position: absolute;
left: 50%;
transform: translateX(-50%);
/* [horizontal] == right */
position: absolute;
right: 0;
/* [horizontal] == fill */
position: absolute;
left: 0;
right: 0;
/* [vertical] == top */
position: absolute;
top: 0;
/* [vertical] == center */
position: absolute;
top: 50%;
transform: translateY(-50%);
/* [vertical] == bottom */
position: absolute;
bottom: 0;
/* [vertical] == fill */
position: absolute;
top: 0;
bottom: 0;
Also, I'd like to add outer-*
values:
/* [horizontal] == outer-left */
position: absolute;
right: 100%;
/* [horizontal] == outer-right */
position: absolute;
left: 100%;
/* [vertical] == outer-top */
position: absolute;
bottom: 100%;
/* [vertical] == outer-bottom */
position: absolute;
top: 100%;
The only problem with outer-*
values is that they can't be implemented with flexbox (or at least I don't know how to do this).
To be honest, I don't think that centerMethod
option was a good idea. Because flexbox
operates on element's children and position: absolute
operates on element itself. They aren't interchangeable. It doesn't really matter when you write code, because there is no big difference where you put @util center
: in a child or in a parent. But if you will decide to move from "transition" method to "flexbox" you will find that you can't just change centerMethod: transform
to centerMethod: flexbox
and expect that your code will use flexbox now. You'll should manually move all @util center
from child to parent. So, I don't see any advantages of centerMethod
in front of two explicit and separated utils (align
for "transform" method and align-children
for "flexbox" method). Also, if you agree to add outer-*
values to align
then align
and align-children
will have different capabilities and it will be nice to have access to both of them in code.
from postcss-utilities.
Related Issues (20)
- Use flexbox to center vertically HOT 5
- Use flexbox for sticky footer
- more customization to `hr` HOT 2
- Syntax highlight HOT 1
- Bump postcss dependency ^6.0.0? HOT 1
- Background image HOT 2
- Add max/min to size utility HOT 1
- "centerMethod" option doesn't work as intended HOT 2
- Add visibility:hidden to clearfix HOT 3
- Bug with centerMethod option HOT 2
- Use PostCSS 7 HOT 1
- Does not support stylus or sass? HOT 1
- Potentially update clearfix util to be more modern HOT 2
- Documentation for @util circle output is incorrect HOT 1
- @util hr - should be able to pass 0-4 parameters without any warnings
- Add text-stroke HOT 2
- fixed sticky footer HOT 5
- @util position if all 0 doesn't work HOT 1
- triangle-framed (non-filled) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postcss-utilities.