Шаблон:Messagebox

Материал из РациоВики
Перейти к навигации Перейти к поиску
If you are seeing this instead of your message, type 2= before your message.
(i) Документация
Warning icon orange.svg This template is used on a large number of pages.

In order to prevent unnecessary server load, edits should be kept to a minimum. Please experiment in the template's /sandbox or /testcases subpage, or in your own sandbox, and consider discussing your changes on the talk page before applying them.

Information icon.svg Editing a template causes all pages that use the template to be re-rendered. If the template is used often, this can put a lot of load on the server since it fills up the job queue.

Parameters

The first unnamed parameter will determine the icon displayed and give the table a class.

parameter icon class resulting style
warning Warning icon orange.svg mb-warning-orange
Warning icon orange.svg If you are seeing this instead of your message, type 2= before your message.
warning-orange Warning icon orange.svg mb-warning-orange
Warning icon orange.svg If you are seeing this instead of your message, type 2= before your message.
warning-red Warning icon.svg mb-warning-red
Warning icon.svg If you are seeing this instead of your message, type 2= before your message.
info Information icon.svg mb-info
Information icon.svg If you are seeing this instead of your message, type 2= before your message.
question Question icon.svg mb-question
Question icon.svg If you are seeing this instead of your message, type 2= before your message.
error Error icon.svg mb-error
Error icon.svg If you are seeing this instead of your message, type 2= before your message.
stop Stop sign.svg mb-stop
Stop sign.svg If you are seeing this instead of your message, type 2= before your message.
copyleft Copyleft icon.svg mb-copyleft
Copyleft icon.svg If you are seeing this instead of your message, type 2= before your message.
nocopyright No copyright icon.svg mb-nocopyright
No copyright icon.svg If you are seeing this instead of your message, type 2= before your message.
copyright Copyright icon.svg mb-copyright

You can replace the default icon with something else using the image parameter, e.g.:

{{messagebox|warning|image = File.svg| {{lorem ipsum}} }}

produces:

File.svg Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Alternatively, the first parameter can be arbitrary wikicode, e.g. a math tag, or an image of any size:

{{messagebox
|class=mb-centered m1
|1=<math>3x-5y=6</math>
<math>2x+4y=2</math>

<math>x=?</math>
<math>y=?</math>
|2=This article/section deals with mathematical concepts appropriate for a student in mid to late high school.
}}

produces:

This article/section deals with mathematical concepts appropriate for a student in mid to late high school.
{{messagebox
|class=mb-centered
|[[File:Human.gif|200px]]
|This user is an idiot.
}}

produces:

Human.gif This user is an idiot.

It can also be omitted entirely, in which case no icon will be displayed.

See the Icons category for more icons.

The second unnamed parameter will be the contents of the messagebox.

The class parameter can be used to add one or more css classes to the box. For example, mb-fullwidth will make the box 100% wide instead of 80%.

Multiple classes should be separated by whitespace.

class resulting style
mb-fullwidth
If you are seeing this instead of your message, type 2= before your message.
mb-centered
If you are seeing this instead of your message, type 2= before your message.
mb-autowidth
If you are seeing this instead of your message, type 2= before your message.
mb-nomargin mb-autowidth
If you are seeing this instead of your message, type 2= before your message.
mb-brainwatermark-light
If you are seeing this instead of your message, type 2= before your message.
mb-brainwatermark-dark
If you are seeing this instead of your message, type 2= before your message.

Nesting

You can use a messagebox within the text part of a messagebox. The nested messagebox will automatically be shrinked, its borders will be removed and a separator line will be added above.

Information icon.svg Info text
Warning icon orange.svg warning text

Styling

The class parameter can be used to add a class specific to one template, to change the style of that one template. For example, Template:Mothball uses the class mothball to change the background color.

To avoid name clashes use the mb prefix for messagebox class names.

To style the messagebox using a class, use the css selector .messagebox.classname. For example, the background of Template:Mothball is changed by the following code [1]:

.messagebox.mothball {
   background-color: #FFC;
}

To style the table cells (both the image and the text):

table.messagebox.classname td {
   background-color: red;
}

The table cells also have classes that allow you to style them separately, these are mb-image and mb-text. The following example changes the background color of the image to green and the font color of the text to blue:

table.messagebox.classname td.mb-image {
  background-color:green;
}

table.messagebox.classname td.mb-text {
  color:blue;
}

Note that since the purpose of this template is to give message boxes a consistent look, per-template styling should be kept to a minimum.

Во избежание поломок страниц, использующих данный шаблон, желательно экспериментировать в своём личном пространстве.