• Resolved roelof

    (@roelof)


    I try to port a non-wordpress theme to a block wordpress theme and now I wonder how I can take care that a group has a width of 100% and a max-width of 630px in gutenberg.

    In normal css I would do this:

    main {
    width: 100%;

    max-width: 630px}

    • This topic was modified 9 months ago by roelof.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Moderator bcworkz

    (@bcworkz)

    width: 100%; along with a max-width value as well is usually fine, but applicability varies quite a bit from theme to theme and from page to page. main may or may not be an appropriate selector to use. Use your browser’s element inspector tool to help you determine the appropriate selectors for your site.

    If you need more specific advice, we’d need a live link to a page demonstrating your typical content. We’d then use the same element inspector tool on it. The only difference is some of us might be more experienced than you in using the tool.

    Thread Starter roelof

    (@roelof)

    if you mean the theme that im try to build can be found here : https://www.free-css.com/free-css-templates/page293/bricker

    and the theme that I use as base is the twentytwentyfour theme.
    The css that I pasted is from the bricks theme.

    And I like to know how can I make that css work in wordpress

    Moderator bcworkz

    (@bcworkz)

    2024 theme styling is normally defined via theme.json, but it can utilize conventional CSS as well. If you’ve copied the 2024 theme and renamed it, all conventional CSS can reside in its style.css file.

    I would expect the HTML from 2024 theme to be very different than that used by Bricks. While you can use Bricks CSS, you’d need to go through and modify most of the selectors used to match your site’s HTML.

    I have difficulty editing code created by others, I often find it difficult to understand their intent. So I would never try to import CSS from one site into another. If I like the appearance of a particular site, I would use it only as guidance in developing my own CSS that matches my site HTML but causes it to look like the model site.

    The link I was looking for is one to your own site or one that has identical HTML content. It would only be useful if you need specific advice about a specific problem that you’re having trouble with.

    Thread Starter roelof

    (@roelof)

    I have problems to make it work that the whole site has a max-width of 1620 which is the wide width of wordpress or 1520px which is the max-width of the bricks one.

    Right now I have to set the wide width on every group and I find that annoying.

    That is why I can tell wordpress how I can set the width of 100% and the max-width of 1520 or 1620 on the whole site instead of each block.

    Moderator bcworkz

    (@bcworkz)

    A site’s overall width in block themes is defined under “layout” in theme.json. Classic themes set the overall width in $GLOBALS['content_width']

    However, individual template or block styling can override this. Ideally, any default content wouldn’t have any specific width styling, allowing the theme.json value to control width. But if you already have content with individual width styling, then yes, it’d be quite annoying to remove them in every block. If you could identify where these widths are saved, it might be feasible to do a DB search and replace operation to alter all the saved widths at once.

    Thread Starter roelof

    (@roelof)

    Oke

    So it a better way to set all blocks one for one at the wide width.
    I see that for the twentytwentyfour theme this is in the theme.json

    “layout”: {

                “contentSize”: “620px”,

                “wideSize”: “1280px”

            },

    Is it a good idea to change the contentSize and wideSize both to 1520px.
    Or can I better do it in the custom css with the main tag ?

    Moderator bcworkz

    (@bcworkz)

    If you change the theme’s theme.json file, your changes will be reverted during the next update. To ensure your changes persist you should create a child theme.
    https://developer.www.ads-software.com/themes/advanced-topics/child-themes/

    Thread Starter roelof

    (@roelof)

    Thanks,

    Then I have to copy the theme.json and then I also can change all the colors and more.

    Do I then have the copy it all or only the parts that I want to change like the colors and then css for underlining links in the navigation.

    Moderator bcworkz

    (@bcworkz)

    Only copy over the files you want to alter. A child theme will continue to use any parent theme files that were not copied over. The one exception is functions.php or any PHP code with named function declarations. This would result in duplicate function names which is not allowed in PHP. Create your own functions.php, do not copy it from the parent. If you want to alter the behavior of theme PHP code, either use any available filter and action hooks; or if a function is a “pluggable” function, then you actually can make a duplicate declaration and alter your version’s code.

    Pluggable function declarations will begin with code similar to:

    if ( ! function_exists( 'theme_function_name' ) ):
    function theme_function_name( $args ) {
    Thread Starter roelof

    (@roelof)

    Thanks,

    I think I only need to rewrite the colors and some css.
    So if I understand you well , I can make a theme.json with only those changed values.

    Moderator bcworkz

    (@bcworkz)

    TBH I’ve no experience making child themes from block themes. I’ve made dozens of child classic themes, but no block themes yet. AFAIK you understand correctly.

    Proceed with that understanding since it’s the simplest to implement. If it doesn’t work right for any reason we can learn together what the proper course of action should have been ??

    Thread Starter roelof

    (@roelof)

    Thanks for your help so far .

    Time to experiment and see if this works better

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘how to set a max-width ?’ is closed to new replies.