Site logo

[Resolved] Having text display properly in mobile for WooCommerce info/message/error banner

Home Forums Support [Resolved] Having text display properly in mobile for WooCommerce info/message/error banner

Home Forums Support Having text display properly in mobile for WooCommerce info/message/error banner

  • This topic has 10 replies, 2 voices, and was last updated 5 years ago by David.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1685052
    Dominique

    Hi,

    In mobile view the WooCommerce info/message/error banner wraps the text to the left and around the continue shopping button. .woocommerce-info, .woocommerce-message, .woocommerce-error

    How can I have the message text appear on top centered and the button underneath centered so it actually looks like an adult did it instead of a 7 year old. A bit a padding between the message and button would make it look even more appropriate.

    Please advise

    #1685331
    David
    Staff
    Customer Support

    Hi there,

    try this CSS:

    @media(max-width: 600px) {
      .woocommerce-info,
      .woocommerce-message {
        display: flex;
        flex-direction: column-reverse;
        text-align: center;
      }
    
      .woocommerce .woocommerce-info .button, 
      .woocommerce .woocommerce-message .button {   
        display: block;
        margin-top: 10px;
      }
    }
    #1685336
    Dominique

    Hi,

    Not 768px?

    Do I have to add .woocommerce-error?

    Like this:

    
    @media(max-width: 768px) {
      .woocommerce-info,.woocommerce-message, .woocommerce-error {
        display: flex;
        flex-direction: column-reverse;
        text-align: center;
      }
    
      .woocommerce .woocommerce-info .button, .woocommerce .woocommerce-message .button, .woocommerce-error .button  {   
        display: block;
        margin-top: 10px;
      }
    }
    
    #1685342
    Dominique

    Hi,

    The button is taking the whole width of the screen.

    I lost my 10 px right and left.

    Please advise

    #1685555
    Dominique

    Hi,

    
    @media(max-width: 768px) {
    	.woocommerce-info, .woocommerce-message, .woocommerce-error {
    	display: flex;
    	flex-direction: column-reverse;
    	text-align: center;
    	}
    	
    	.woocommerce .woocommerce-info .button, .woocommerce .woocommerce-message .button, .woocommerce-error .button  {   
    	display: block;
    	margin-top: 10px;
    	margin-right: auto;
    	margin-left: auto;
    	}
    }
    

    It’s a good? 🙂

    #1685665
    David
    Staff
    Customer Support

    Looks good to me.
    Couple of points:

    1. woocommerce-error is not required in this instance – but you may have a similar issue with the error notices.

    2. The 600px vs 768px – you can set the value to wherever you want the content to be stacked. Simply resize the browser to see where its necessary for the content to stack.

    #1685672
    Dominique

    Hi,

    Other points.

    Since flex-direction: column-reverse; is used some messages are displayed in reversed order. I removed the selector .woocommerce-info everywhere.

    Most likely as you mentioned .woocommerce-info is not needed also as there are no buttons within those messages I think. I need to generate some errors. Don’t know how to…

    #1685677
    Dominique

    Oups typo

    Most likely as you mentioned .woocommerce-error is not needed also as there are no buttons within those messages I think. I need to generate some errors. Don’t know how to…

    #1686463
    David
    Staff
    Customer Support

    Yep – that makes sense. Errors – most likely will be found on Checkout if users miss out key fields.

    #1686814
    Dominique

    Hi,

    Worse case if there’s a button in an error message it will just look like a 7 year old coded it.

    If it can help anyone else evised code:

    
    @media(max-width: 768px) {
    	.woocommerce-message {
    	display: flex;
    	flex-direction: column-reverse;
    	text-align: center;
    	}
    	
     .woocommerce .woocommerce-message .button {   
    	display: block;
    	margin-top: 10px;
    	margin-right: auto;
    	margin-left: auto;
    	}
    }
    

    Thanks for your help.

    #1686873
    David
    Staff
    Customer Support

    🙂
    Glad to be of help.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.