• Resolved krischan941

    (@krischan941)


    Hello,
    I’d like to have the comment fields border-style in posts to be dashed 1px with border-color #c27113 when they are focused. Currently they are solid. How can I achive this?
    I got it to work in the contact form https://storch.watch/kontakt/ (which is a seperate Worpress-Plugin) but struggle to get it work in comment fields.

    What I tried in custom css is:

    .wp-block-post-comments-form textarea:focus, .wp-block-post-comments-form input:focus {
    	border-style: dashed !important;
    	border-color: #c27113 !important;
    }

    but it doesn’t work. Even

    textarea:focus, input:focus {
    	border-style: dashed !important;
    	border-color: #c27113 !important;
    }

    doesn’t change something.

    Thanks in advance
    Christian

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Kathryn Presner

    (@zoonini)

    Hi @krischan941 – I spot-checked your site but couldn’t quickly find an example of a comment form. Would you be able to provide a link to a post with a comment form so I can have a look?

    Thread Starter krischan941

    (@krischan941)

    Hello @zoonini
    thanks for your answer. Sorry I forgot to post a specific site. Here is one:
    https://storch.watch/2022/07/11/der-storch-ist-online/

    I’d like the comment form style to behave like the contact form stlye:
    https://storch.watch/kontakt/

    Moderator Kathryn Presner

    (@zoonini)

    Thanks for the link to a sample comment form.

    Before we get into the focus state on the fields there, I noticed that you’ve been adding custom CSS to the Twenty Twenty-Two style.css file directly. It’s not advisable to do that, because the next time the theme is updated, all your custom CSS will be wiped out.

    Have you been modifying other theme files in addition to style.css?

    If not, I’d suggest you add your custom CSS to the built-in CSS editor instead. You can access it here:

    https://storch.watch/wp-admin/customize.php

    If you have changed other files as well, I’d strongly recommend you create a child theme instead. A child theme will keep your changes safe when the theme is updated in the future. The simplest way to make a child theme of a block theme (a theme that supports Full Site Editing, like Twenty Twenty-Two) is by using the plugin Create Block Theme. Once your child theme is created, you can go ahead and deactivate the plugin.

    As for the CSS, the current outline is coming from the focus: visible state, the look of which is controlled by the browser.

    To remove it and add your orange dotted outline instead, try this:

    /* Comment form fields */
    .comment-form textarea:focus-visible,
    .comment-form input:focus-visible {
      outline: none;
      border-style: dashed;
      border-color: #c27113;
    }

    Do keep in mind that the outline is mainly there for accessibility reasons, so ideally you wouldn’t remove it. See here for more info:

    https://hacks.mozilla.org/2019/06/indicating-focus-to-improve-accessibility/

    Thread Starter krischan941

    (@krischan941)

    Thank you for your reply.

    To the css: I know it wasn’t clever to put my custom css in the stlye.css directly. As you recommended me elsewhere https://wordpress.org/support/topic/problems-with-creating-a-child-theme/ I used the Plugin “Create Block Theme” and “exported my current theme”. But I see it’s bad practice with edited style.css.

    I just created a Child-Theme. I reset the style.css to the init state and created a Child Theme with “Create Block Theme” and loaded it aftwerwards. Is it then correct to put the custom css (with my customizations only) in the child style.css? If yes that did nothing unfortunately. The child style.css header has a correct header with “theme: twentytwentytwo”.
    As long as the child theme doesn’t run properly I load the parent Twenty Twenty Two Theme with css customizations written down in https://storch.watch/wp-admin/customize.php as you suggested!

    To the comment form: thanks for the information to the outline property, I wasn’t aware of it. I’ll see how I handle it.
    Btw. have you any idea how one can see in the webbrowser devtools the :active, :focus, Focus-visible etc. properties?

    Thank you very much for your good help.

    • This reply was modified 1 year, 8 months ago by krischan941.
    Moderator Kathryn Presner

    (@zoonini)

    I used the Plugin “Create Block Theme” and “exported my current theme”. But I see it’s bad practice with edited style.css.

    Ah, I see. Doing that is called “forking” the theme, rather than creating a child theme. Forking a theme by making a copy of it means that if Twenty Twenty-Two gets updated in the future, your site wouldn’t get those updates. The benefit of making a child theme is that you do get the benefit of Twenty Twenty-Two theme updates in the future, while preserving your changes.

    It would still be good if you can answer my question, since this would help me better understand if you actually need a child theme or not:

    Have you been modifying other theme files in addition to style.css?

    If all you want to do is add custom CSS, then using the custom CSS editor is the simplest route, and you don’t need a child theme, nor would you need to fork the theme.

    • This reply was modified 1 year, 8 months ago by Kathryn Presner. Reason: fixed typo
    Thread Starter krischan941

    (@krischan941)

    It would still be good if you can answer my question, since this would help me better understand if you actually need a child theme or not:

    Have you been modifying other theme files in addition to style.css?

    Ah I forgot. Yes, I have modified the style.css only.

    So now, as you suggest I just use the Twenty Twenty Two theme with my css in the custom css editor 🙂

    • This reply was modified 1 year, 8 months ago by krischan941.
    Moderator Kathryn Presner

    (@zoonini)

    Perfect, glad you’re set for now!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Border style of comment field’ is closed to new replies.