Handling mobile specific styling #503
-
I am trying to figure out a way, any way, to implement the ability to make mobile only style settings (media query stuff). Using the landing page example as an example here. The container component has margin and padding options that adjust the inline styling of the container. These inline styles override all css classes, etc. So, while this might look fine setting these in a desktop layout, the mobile layout looks off, and you will need some way to adjust the margin/padding for mobile only. Now, since you can't inline media queries, I can't think of how this can be done. Other page builders that I've seen will either make a separate css file or add styles to the header of the rendered html file. But I'm not sure if this is possible with Craft.js. Any help or ideas here would greatly be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Ok, I'm pretty sure I figured out how to accomplish this. I ended up using So for anyone interested, this is what the
|
Beta Was this translation helpful? Give feedback.
Ok, I'm pretty sure I figured out how to accomplish this. I ended up using
styled-components
since you can pass props to the component and it will modify the css on the fly. I was struggling there for a bit because I'm using TailwindCSS for the bulk of the project and you can't use dynamic classes, even with JIT enabled. Plus inline styling just wouldn't work.So for anyone interested, this is what the
container
component resulted as. This allows me to pass additional mobile settings to it.