Comments (14)
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
from gutenberg-starter-theme.
> *
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.
@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.
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.
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.
> *
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.
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.
Anyone up for making a PR trying it out?
from gutenberg-starter-theme.
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.
PR: #35
Here's a before (master branch) of the Gutenberg demo content page:
With PR:
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, notalignfull
. -
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):
from gutenberg-starter-theme.
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.
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
:
That works great, but in this theme, the article
's direct children are actually header
, div
, and footer
:
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
:
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:
from gutenberg-starter-theme.
Closing as merged.
from gutenberg-starter-theme.
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)
- not identical backend/frontend HOT 1
- Adobe Accessible Mega Menu
- Modernize the dev workflow
- Site Editor question HOT 2
- Gutenberg Demo broken HOT 3
- h5 and h6 span full width HOT 2
- Enqueue /css/blocks.css with enqueue_block_assets? HOT 2
- Alignment of images left or right next to text blocks HOT 2
- Demo broken HOT 2
- Resized image Does not display HOT 3
- Featured Images don't appear, even though the theme supports them. HOT 8
- Search and 404 needs styling HOT 3
- Block color palette names should be translatable HOT 1
- Add contextual color classes for editor color palette colors HOT 1
- Wrong condition in header.php for `site-title` HOT 3
- Element "Read more" has no max-width applied, as not displayed as block-element
- Not an issue, just an inquiry about Sass functionality? HOT 1
- browser upscaling
- readme.txt inaccurate
- Newbie question HOT 1
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 gutenberg-starter-theme.