Giter Site home page Giter Site logo

Comments (2)

ismamz avatar ismamz commented on May 27, 2024

Great idea! Could you detail for all the cases what would be the resulting code?

from postcss-utilities.

revyh avatar revyh commented on May 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.