GithubHelp home page GithubHelp logo

Comments (14)

youknowriad avatar youknowriad commented on May 27, 2024 3

Just a small clarification. The :not selector is correctly supported by all browsers, it's the multiple arguments for this selector that is not widely supported

https://caniuse.com/#search=%3Anot

screen shot 2018-02-13 at 17 06 57

from gutenberg-starter-theme.

amdrew avatar amdrew commented on May 27, 2024 1

> * could work, just not sure about performance (granted it's only selecting all direct children of .entry-content):

.entry-content > * {
    margin: 1.5em auto;
    max-width: 740px;
    padding-left: 20px;
    padding-right: 20px;
}

from gutenberg-starter-theme.

karmatosed avatar karmatosed commented on May 27, 2024 1

@jasmussen may have solved this in a similar way so throwing in for a suggestion:

article > *:not( .alignwide ):not( .alignfull ) { max-width: 50%; margin-left: auto; margin-right: auto; }

https://codepen.io/joen/pen/oEzYxb

from gutenberg-starter-theme.

amdrew avatar amdrew commented on May 27, 2024 1

Circling back to the initial comment on this issue (#30 (comment)):

So we don't have to manually center every block by hand. Is there a shared class we can call on?

It be great if there actually was a shared class that existed. Thinking outside the bounds of this theme, we can never guarantee that a theme even has an .entry-content div. Some themes might also have .entry-content applied to multiple elements.

Something like .wp-block added to every block would be ideal (and perhaps filterable?). This would allow us to ditch the > * selector and just target .wp-block which we know will always be a block.

Anyone agree/disagree? An issue for the Gutenberg repo perhaps?

from gutenberg-starter-theme.

youknowriad avatar youknowriad commented on May 27, 2024 1

Something like .wp-block added to every block would be ideal (and perhaps filterable?). This would allow us to ditch the > * selector and just target .wp-block which we know will always be a block.

Right now, this won't be possible because some blocks like the "classic block" don't have wrappers.

from gutenberg-starter-theme.

BE-Webdesign avatar BE-Webdesign commented on May 27, 2024

> * is my personal go to, then any widths that extend beyond that can be changed on a class by class basis.

from gutenberg-starter-theme.

karmatosed avatar karmatosed commented on May 27, 2024

Does that work across all device though? Also what about where there are classes on entry-content? Would be great maybe to get a PR.

from gutenberg-starter-theme.

melchoyce avatar melchoyce commented on May 27, 2024

Anyone up for making a PR trying it out?

from gutenberg-starter-theme.

BE-Webdesign avatar BE-Webdesign commented on May 27, 2024

Does that work across all device though? Also what about where there are classes on entry-content? Would be great maybe to get a PR.

Here is the support.

from gutenberg-starter-theme.

amdrew avatar amdrew commented on May 27, 2024

PR: #35


Here's a before (master branch) of the Gutenberg demo content page:

before2


With PR:

after2


Notes:

  • The image width in the first image changed but that's because the demo actually has a class of alignwide on the first image, not alignfull.

  • I don't think :not is necessary since the .alignwide and .alignfull selectors can easily override the previous styles. The browser support doesn't appear to be the best either (https://caniuse.com/#search=%3Anot):

screen shot 2018-02-10 at 2 43 52 am

from gutenberg-starter-theme.

karmatosed avatar karmatosed commented on May 27, 2024

I think to work across all instances article is better maybe @amdrew - is there a reason you didn't use the version suggested? I think the :not does have a value where overriding isn't needed, but I'd want to be sure.

from gutenberg-starter-theme.

amdrew avatar amdrew commented on May 27, 2024

is there a reason you didn't use the version suggested?

Yes, the CodePen (https://codepen.io/joen/full/oEzYxb/) assumes that all blocks are a direct child of article:

screen shot 2018-02-12 at 12 03 03 am

That works great, but in this theme, the article's direct children are actually header, div, and footer:

screen shot 2018-02-12 at 12 05 14 am

We need to target the direct children of whichever element houses all the blocks. In the theme, this is the div with the class of .entry-content.

This shows all the blocks are direct children of .entry-content:

screen shot 2018-02-12 at 12 18 01 am

We could still use the suggested code with :not, but we'd need to change the initial selector so it's .entry-content (not article), meaning the direct children (the blocks) are properly targeted:

.entry-content > *:not( .alignwide ):not( .alignfull ) {
// code here
}

We'd then need to fix the image in the demo being full-width, since it has the alignwide class applied to it. .wp-block-cover-image is overriding it with its 100% width:

screen shot 2018-02-12 at 12 40 02 am

from gutenberg-starter-theme.

karmatosed avatar karmatosed commented on May 27, 2024

Closing as merged.

from gutenberg-starter-theme.

anybodesign avatar anybodesign commented on May 27, 2024

I agree that the class .wp-block should be added to every block, seems logical to me, and easier to target all blocks with CSS.

from gutenberg-starter-theme.

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.