Issue #922💬 AnsweredOpened March 2, 2018by mbleverage0 reactions

Adding default styling to a component

Quick answerby artf

Your change on the block doesn't work because you don't change the actual component (just the block's property) With cssComposer instead, by default, selectorManager accepts classes An easier way to add custom CSS might be this one But be careful, if store your templates and then run this command on any refresh this w...

Read full answer below ↓

Question

I have been working on integrating grapesjs into a new development I'm working on. I have had much success with the documentation and wiki forum but am running into a few issues I'm hoping someone out there can help me with. I am working with a mobile view only, I have set the default device to mobile and hidden the option to change. When I insert an image, I would like the default css to include max-width: 100% as if I load a large image into the mobile view I will get an image much larger than the screen I'm looking at. I have tried: But I realize that might be an incorrect use and maybe on...

Answers (3)

artfMarch 4, 2018

Your change on the block doesn't work because you don't change the actual component (just the block's property) With cssComposer instead, by default, selectorManager accepts classes An easier way to add custom CSS might be this one But be careful, if store your templates and then run this command o...

mbleverageMarch 5, 2018

Thank you! I was able to get that working with: protectedCss: 'img {max-width:100%;}', I have the same issue with videos and iframes (for youtube) being dropped onto the template larger than the screen size and the protectedCss solution did not work for those. Any suggestions?

artfMarch 6, 2018

protectedCss is loaded so the CSS is here, if it doesn't work probably your CSS technique is not correct

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.