Tài liệu bản mẫu[xem] [sửa] [lịch sử] [làm mới]

Bản mẫu này dùng để tạo các hộp chữ đơn giản, dễ tuỳ chỉnh màu sắc.

Xin lưu ý rằng bản mẫu này chỉ được dùng với mục đích trang trí và không có giá trị trong bách khoa toàn thư tổng quát. Nó không hiển thị trên các bài viết.

Mục đích sửa

Wikipedia có rất nhiều bản mẫu sử dụng khung viền, ví dụ:

Khung viền không phải lúc nào cũng phù hợp; đôi khi nó gây khó chịu. Nhưng khi sử dụng khung viền, các thành viên khác nhau định dạng nó theo các cách khác nhau của riêng họ. Điều này dẫn tới sự không thống nhất.

Bản mẫu {{Divbox}} mang tới một phương pháp đơn giản để biểu diễn văn bản trong khung. Màu sắc được lựa chọn dựa trên một từ khoá định nghĩa sẵn, có tác dụng định dạng viền khung và nền.

Bản mẫu này có thể được dùng bên trong một bản mẫu khác; hoặc trong một trang khác.

Cách sử dụng sửa

Cấu trúc cú pháp chung của bản mẫu này như sau:

{{divbox|1=style|2=title|3=content|radius=}}

Các tham số sửa

1 (Kiểu)
Bắt buộc. Sử dụng bất kỳ cách nào sau đây:
Bạn có thể bỏ qua "1=", miễn là bạn để tham số màu là tham số đầu tiên không có tên trong bản mẫu.
2 (Tiêu đề)
Tuỳ chọn. Chữ bình thường; được định dạng đậm và căn giữa trên đầu khung. Bạn có thể bỏ qua "2=", miễn là thoả mãn điều kiện tương tự như trên
3 (Nội dung)
Bắt buộc. Nội dung gì cũng được, kể cả các mã định dạng. Đây sẽ là nội dung chính của thông điệp trong hộp. Có thể bỏ qua "3=" miễn là thoả mãn các điều kiện như trên.
radius
Bán kính của viền tròn bao quanh hộp, phải có đơn vị cụ thể như px, pt hay em. Bạn có thể bỏ qua tham số này nhưng không được bỏ qua tên của nó "radius=" (có phân biệt hoa thường).

Các ví dụ sửa

Những gì bạn nhìn thấy Những gì bạn gõ
gray: {{divbox|gray|Lorem ipsum|Lorem ipsum dolor...}}
red: {{divbox|radius=5px|red|Lorem ipsum|Lorem ipsum dolor...}}
navy: {{divbox|radius=10px|navy|Lorem ipsum|Lorem ipsum dolor...}}
amber: {{divbox|radius=15px|amber|Lorem ipsum|Lorem ipsum dolor...}}
Không có khung viền hoặc màu nền: {{divbox|none|Lorem ipsum|Lorem ipsum dolor...}}
Không có tiêu đề {{divbox|navy||Lorem ipsum dolor...}}
Nội dung chứa '=': {{divbox|lavender|Lorem ipsum|3=Lorem <span style="color:#F00;">ipsum</span> dolor...}}

Sử dụng thế: có bản mẫu này sửa

The thế: atom may be used with {{divbox}}. This may be highly desirable. Note that thế: does not take effect in preview, but only after saving a page. The template's inclusion is replaced by the code of the template itself, which will continue to write the box as before, but without an additional server call.

Since {{divbox}} itself calls a template based on your choice of style keyword, you will find that even after saving an instance of use with thế: there remains a "live" call to the underlying style template. This means that viewing the page risks a server call to the style template, but also means that changes to the style template automatically propagate to all pages where it is used. This way, all {{divbox}}-type boxes, wherever they are in the project, keep the same consistent look.

Just paste in your content and, when you're finished, be sure to close the template call with }}.

Since the contents are given in the form of two parameter values, for the content you may place within {{divbox}}, the restrictions on parameter values apply. For example, if you put content that includes template calls, {{divbox}} cannot tell where its last parameter ends.

If the contents do not satisfy the restrictions, insert this code in your page first:

{{thế:divbox|keyword|title|DUMMYCONTENT}}

That is, choose your style and title as usual (or omit the title with two pipes), but instead of actual content, write "DUMMYCONTENT". Then, save the page and reopen it for editing. You'll see the box code in all its gory detail, and the placeholder DUMMYCONTENT, followed by the HTML division closing tag. Now, you may simply replace DUMMYCONTENT with your content, save, and move on. Since almost anything may be placed within division tags, this should not break no matter what you do.

Tạo kiểu divbox mới sửa

I'd rather hope you were able to find joy within the existing set of styles, but if not, you can create new ones. Follow these instructions to be sure your new style will "play nice" with {{divbox}}. Note that this requires some understanding of CSS.

  1. Experiment in a drawing program, such as GraphicConverter or Adobe Photoshop, and decide what colors you want for your new box style. You need to find out the HTML color codes for each color.
  2. Open an existing box style template, such as {{divbox/style/red}}. Copy out the code.
  3. Create a new box style template page. It must be located in main Template namespace and must be named Bản mẫu:divbox/style/XXXXX, where "XXXXX" is your new style name.
  4. Paste in the "borrowed" code and replace the color codes with your new, chosen colors. Save the new template.
  5. Return to this Talk page and add your new style to this documentation. Remember, a job's not over until the paperwork is done!

Note that you may even change the division box margins and paddings. This is not recommended. There are a couple of good reasons for specifying these values, and in these units. Most users who "roll their own" make choices with unintended consequences; {divbox} is meant to help you avoid these pitfalls.

Xem thêm sửa

Có 7 siêu bản mẫu trong gia đình hộp thông báo (Mbox):

  • {{Hộp thông báo}} (Ambox) – dùng cho không gian tên Chính (bài viết)
  • {{Hộp thông báo thể loại}} (Cmbox) – dùng cho không gian tên Thể loại
  • {{Hộp thông báo thảo luận}} (Tmbox) – dùng cho không gian tên Thảo luận
  • {{Hộp thông báo hình}} (Imbox) – dùng cho không gian tên Tập tin
  • {{Fmbox}} – các hộp thông báo dạng footer và header
  • {{Ombox}} – dùng cho các không gian tên khác (Thành viên, Wikipedia,…)
  • {{Mbox}} – tự động kiểm tra không gian tên, dành cho hộp thông báo được sử dụng tại nhiều không gian tên và do đó cần thay đổi kiểu tùy vào nơi chúng được dùng.

Siêu bản mẫu có liên quan gần:

  • {{Hộp sơ khai}} (Asbox) – siêu bản mẫu dành cho hệ thống bản mẫu sơ khai.
  • {{Dmbox}}, cho các hộp thông báo trên các trang định hướng hoặc trang chỉ mục.
  • {{Ivmbox}}, một hộp đơn giản có chiều rộng đầy đủ với nền ngà mặc định dành cho các thông điệp hoặc thông báo quan trọng.