Giter Site home page Giter Site logo

Comments (3)

mikke89 avatar mikke89 commented on August 29, 2024

Hey there. I'm trying to understand what you expect to happen in this situation, can you elaborate?

The result looks as I would expect here. Transforms should not affect the width of parent elements, and neither should positioned elements. I believe this behavior is the same as in CSS.

By the way, the idiomatic way in RmlUi to center elements is to use margin: 0 auto. This has the advantage that it is determined at the layout stage, so you get the benefit of pixel-aligned boxes and textures. On the other hand, transforms are done at the rendering stage, with possibly subpixel positioning, which can lead to slightly blurred text and textures. This approach also works better with clipping in our library.

from rmlui.

Lyuu17 avatar Lyuu17 commented on August 29, 2024

Hey there. I'm trying to understand what you expect to happen in this situation, can you elaborate?

left: -50%; transform: translateX(50%); is supposed to center horizontally the div (at least what it says in here: https://stackoverflow.com/questions/25982135/why-does-left-50-transform-translatex-50-horizontally-center-an-element)

The result looks as I would expect here. Transforms should not affect the width of parent elements, and neither should positioned elements. I believe this behavior is the same as in CSS.

yeah, sorry, i'm bad for titles

By the way, the idiomatic way in RmlUi to center elements is to use margin: 0 auto. This has the advantage that it is determined at the layout stage, so you get the benefit of pixel-aligned boxes and textures. On the other hand, transforms are done at the rendering stage, with possibly subpixel positioning, which can lead to slightly blurred text and textures. This approach also works better with clipping in our library.

The thing is, I don't want to use the whole screen for the document so I wanted to use position: absolute but I guess this is easier and less headache

from rmlui.

mikke89 avatar mikke89 commented on August 29, 2024

By the way, make sure to give body a width. Otherwise, there is nothing to compute percentages relative to, so they will resolve to zero. For me, it works perfectly fine to center it with the way you mention here, after setting width: 100% on the body. If you have any issues, try to test with the latest master branch, as there are several layout changes since RmlUi 5.1.

The thing is, I don't want to use the whole screen for the document so I wanted to use position: absolute but I guess this is easier and less headache

You can use margin: auto with position: absolute to center the element (at least if the sizes are fixed).

from rmlui.

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.