Giter Site home page Giter Site logo

oliverzheng / howtocenterincss Goto Github PK

View Code? Open in Web Editor NEW
1.1K 19.0 47.0 178 KB

CSS generator for centering text/div depending on their size or the container size.

Home Page: http://howtocenterincss.com/

CSS 4.05% JavaScript 94.08% HTML 1.87%

howtocenterincss's Introduction

How to Center in CSS BuildStatus

Centering in CSS is a pain in the ass. There seems to be a gazillion ways to do it, depending on a variety of factors. This consolidates them and gives you the code you need for each situation.

This is a code generator for your alignment needs.

howtocenterincss's People

Contributors

oliverzheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

howtocenterincss's Issues

Bug: Clicking any unit in "known" selects "px".

  • Chrome 64.0.3282.167
  • macOS 10.13.3

Under "width / known" and "height / known", if a user clicks the "em" or "%" choices (which are styled to look like radio buttons, but whose markup is deceptively composed of divs), the "px" option is always selected. A second click is required for "em" or "%".

This requires extra attention (and extra interaction) from users.

Thank you.

Add tests

A map of options -> method is probably fine. Browser tests seem exhaustive for this.

Support for Safari?

Cool site, coming from InDesign etc I was always bemused by how difficult it was to do "simple" layout things in CSS. I didn't test on IE (no Windows box) but Chrome and Firefox produced the output I was expecting, but Safari didn't ...

I don't see any mention of Safari on the site, so perhaps you don't intend to support it? It appears that Safari doesn't support flex. Crappy gif video showing what I mean:
howtocenterincss-safari

      #app-loading {
        background: white;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items:center;
        font-size: 2em;
      }

Auto scroll down when code is generated

The first time I used the site, I was a bit confused because I couldn't see the code appear below.

Maybe do:

var codeElement = document.getElementById('generated-code')
codeElement.scrollIntoView()

or

document.getElementById('generated-code').scrollIntoView()

Page is not navigable by keypresses (tab, arrow, space).

Because the page is composed mostly of divs rather than inputs, keyboard navigation (by presses of the tab, arrows, and spacebar keys) is not possible.

This slows user interaction, and it would seem to be against ARIA standards.

Thank you.

  • Chrome 64.0.3282.167
  • macOS 10.13.3

Generate code button does nothing

I just tried your nice site, unfortunately the generate code button does not do anything. No code generated, no error message, nothing.

it is doesn't work

it is should align Center and Middle

issue

but on screen, align is Top and Right. it is wrong

Usage of centering inside CSS Grid Layout

I might like to specify the width/height of my divs i.e. rows, in fractions.
Is display: grid; compatible with the flexbox rules proposed by the generator?
Is that a good solution?

Suggestion for the site

I would like to suggest having a clear all or a clear button on each section. Possibly could be a nice feature. I will fork it if you'd like for me to implement that feature to the site. It would be nice to have something for the user to clear their input since there is a lot of input. Also have you considered doing it in AngularJS to implement a live generation as the user inputs things. No issues with your site though just ideas. :D ๐Ÿ‘

Add `inline-block` info

To the question:

Content

What do you want to center?

The option "Text" has description Just text, or an inline-level block of text and images. Change inline-level to inline-level and inline-block level or something like that to make it more clear.

Site is currently broken

http://fb.me/react-0.13.1.min.js Failed to load resource: the server responded with a status of 403 (Forbidden)
bundle.min.js:1 Uncaught TypeError: Cannot read property 'Component' of undefined

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.