Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I define the width of the editor? #6064

Closed
davidperezgar opened this issue Apr 8, 2018 · 20 comments
Closed

How can I define the width of the editor? #6064

davidperezgar opened this issue Apr 8, 2018 · 20 comments
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@davidperezgar
Copy link
Member

Hello, Gutenberg tend to show how it will be in public.
Actually, we work with 1280px grid, and the editor Gutenberg has 610px width, so we should adapt Gutenberg as it will be in public.

How can we change the width of the editor? So, it will show very similar like public?

@weavertheme
Copy link

weavertheme commented Apr 8, 2018

As part of the theme editor CSS, add:

@media screen and ( min-width: 768px ) {
    .edit-post-visual-editor .editor-post-title,
    .edit-post-visual-editor .editor-block-list__block {
	max-width:	1100px;
    }
}

where you use whatever value you need to match your theme width.
Probably don't need the @media, but I put all my display dependent rules in an @media for consistency.

@davidperezgar
Copy link
Member Author

Nice @weavertheme ! thanks! that helped me!

@weavertheme
Copy link

Just figured out you also need one to make the editor's default alignwide width work properly when you extend the width. My opinion is that theme max-width + 200px works pretty well:

.edit-post-visual-editor .editor-block-list__block[data-align="wide"] {
	max-width: 1300px;
}

@designsimply designsimply added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Aug 14, 2018
@raquelmsmith
Copy link
Contributor

This is assuming that every template on a website has the same width. However, one of our templates doesn't show the sidebar, so the content width is wider.

From what I can tell, the editor doesn't add any classes to the body (or otherwise) for the post/page template that is selected. Or am I missing something? Any suggestions for what to do here?

@drdogbot7
Copy link

As of 11/20/18, the code below seems to do the trick, and it's a lot easier to remember. This increases the width of the regular content in the editor, without messing with the 'wide' and 'full' blocks.

.wp-block {
  max-width: YOUR-CHOSEN-WIDTH;
}

@manake
Copy link

manake commented Dec 6, 2018

I have the same question as @raquelmsmith

@kgroveshok
Copy link

Do I get this right then? The post editing sets the area to the size it would appear so it is easier to gauge the final view. That is nice and helpful. However, if I'm editing large amounts of text I don't want to be looking at it through a letter box on a large screen. Is there any switch to wide view irrespective of the finial view? Or am I missing something?

@kgroveshok
Copy link

OK never mind I will switch to the Classic Editor

@designsimply
Copy link
Member

For the question about multiple editor widths, I posted an explanation of the current situation and a workaround code example at #12874 (comment). Please have a look!

@rogerlos
Copy link

rogerlos commented Jan 12, 2019

This seems to sort-of work. But it also seems a bit fragile (SASS shown):

/* From elsewhere in my stylesheets */
$editor_wide: 1300px; 

.wp-block {
  max-width: $editor_wide;
  &[data-align="full"] {
    max-width: none;
  }
  &[data-align="wide"] {
    max-width: calc( #{$editor_wide} + 200px );
  }
}

@rogerlos
Copy link

I wrote a script which watches the template selector, and adds a class to your chosen gutenberg wrapper. Here's a gist with the script, plus sample PHP code to add it and a very simple example of how to use it to target specific templates with CSS:

https://gist.github.com/rogerlos/9c156a580e2a3cfaf862b837cc01e015

@rahulkhosla
Copy link

rahulkhosla commented Feb 23, 2019

@davidperezgar Here's an answer I found for custom editor widths (https://wpza.net/changing-the-width-of-the-gutenberg-editor/).

@IvanPr
Copy link

IvanPr commented Feb 24, 2019

Simply use:
function custom_admin_css() {
echo '<style type="text/css">
.wp-block { max-width: 950px; }
</style>';
}
add_action('admin_head', 'custom_admin_css');

@Jeremy-Bolella
Copy link

Jeremy-Bolella commented Jun 27, 2019

I found this works even better then some of the other answers. Leaves a slight gutter to the left for the gutenberg block dragger buttons

.wp-block {
  max-width: 1200px;
}

.block-editor-writing-flow {
  padding-left: 3rem;
}

@davidperezgar
Copy link
Member Author

Hello, that worked for me, but now, I can't define width in a post type. I use:

.wp-block {
	max-width: 1027px;
}
.post-type-guia .wp-block {
	max-width: 682px;
}

But it seems that is not working for post types...

@davidperezgar davidperezgar reopened this Jun 24, 2021
@davidperezgar
Copy link
Member Author

Any idea to define the width in post types?

@Mamaduka
Copy link
Member

@davidperezgar, try using the following snipped for post types:

.post-type-guia .editor-styles-wrapper .wp-block {
    max-width: 682px;
}

@davidperezgar
Copy link
Member Author

Thanks. Let me try.

@Mamaduka
Copy link
Member

Mamaduka commented Oct 3, 2022

Hi, @davidperezgar

Can we close this issue?

@tomdevisser
Copy link
Member

Closing this as it's inactive and seems to be solved, feel free to reopen it if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests