Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS styling of flash message

What should I use to style my flash messages in my CSS? I can't seem to change it's styling. Here's the relevant code within the <body> of my application layout:

    <div class="container">
      <%= render 'layouts/header' %>
      <section class="round">
        <div id= "notice">
          <% flash.each do |key, value| %>
            <div class="flash <%= key %>">
              <%= value %>
            </div>
          <% end %>
        </div>
        <%= yield %>
      </section>
      <%= render 'layouts/footer' %>
      <%= debug(params) if Rails.env.development? %>
    </div>

The relevant original CSS was something like this but it doesn't currently work.

.error, .alert, .notice, .success, .info {padding:0.8em;margin-bottom:1em;border:2px solid #ddd;}
.success {background:#e6efc2;color:#264409;border-color:#c6d880;}
like image 811
Justin Meltzer Avatar asked Mar 04 '11 05:03

Justin Meltzer


People also ask

How to show flash message in HTML?

If you need to show a flash message without a trigger element (e.g., you want to show the message as a consequence of user actions), you can use the ' showFlashMessage ' custom event.

How to display flash message in JavaScript?

Click on the empty space of the Dynaform to display its properties on the left side of the screen. Then, click on the "edit" button in the javascript property. } ); Now, run the case, click on the "Show message" button and the flash message will be displayed in front of the Checkgroup element.

What are flash messages in Rails?

What are flash messages? A flash message is a way to communicate information with the users of your Rails application so they can know what happens as a result of their actions. Example messages: “Password changed correctly” (confirmation)


1 Answers

Either add a rule for parent div with id notice:

#notice {
  css_formatting_here
}

Or add a rule for child divs:

.flash {
  css_formatting_here
}

The child div of errors container has multiple classes separated by whitespace. flash is one of them. Thus you can add a CSS rule for that class, and it will work.

Look here for more such examples: Hidden features of CSS

like image 114
Nikita Barsukov Avatar answered Oct 06 '22 02:10

Nikita Barsukov