0 users
Search

Friday, March 21, 2008

CSS Message Box collection

0 users

Message boxes are useful elements to display status messages after or during a specific user request. Some days ago I wrote this post about how to implement a nice Ajax chains of effects (fade in, delay, fade out) for a common message box using mootools. Today I want to share with you a collection of some simple CSS styles you can apply to your message boxes (clean, solid, iconized, alternated rounded borders, tooltip).




I added also a link to download a beautiful icon pack to use in your projects to design custom message box or other graphic elements.

Download message box collection source code


Clean message box
I love clean and simple design and in general this is my preferred message box style: a border (1px) and a light background color:


HTML code is very simple:

<div class="clean-gray">Clean message box</div>

...a DIV layer with with some text within. And CSS code is something like this:

.clean-gray{
border:solid 1px #DEDEDE;
background:#EFEFEF;
color:#222222;
padding:4px;
text-align:center;
}

I suggest you to use "pastel" color for the background color and a darker color for the text.


Iconized message box
This is another box style I like. A simple box with an icon in background which describe visually the "event" it represents (ok, error, alert...):




HTML code is the same you saw in the previous example:

<div class="clean-gray">Clean message box</div>

...and the related CSS code is:

.icon-heart{
border:solid 1px #DEDEDE;
background:#FFFFCC url(img/icon-heart.png) 8px 6px no-repeat;
color:#222222;
padding:4px;
text-align:center;
}

If you are looking for nice icons I suggest to download this beautiful icon pack (Sweetie Pack). This is a preview of the content:




You can use it to design your iconized message box or, for example, CSS buttons and other graphic elements for your web projects.


Solid message box
Nothing simpler: a message box with no borders and with text color in contrast with the background color:



HTML code is:

<div class="solid-green">Solid message box green</div>

...and CSS code is:

.solid-green{
background:#008000;
color:#FFFFFF;
font-weight:bold;
padding:4px;
text-align:center;
}

...choose the background color you prefer!


Alternated rounded borders message box
This is anoter nice solution with alternated rounded borders (top-left, bottom-right). The box adapts automatically the rounded borders position with its width and height:



HTML code is the following:

<div class="round-a-gray"><div>Alternated rounded borders message box</div></div>

...a DIV layer inside the main DIV layer with "round-a-gray" class. CSS code is:

.round-a-gray{
background:#444444 url(img/round_gray-left.png) left top no-repeat;
color:#FFFFFF;
text-align:center;
}
.round-a-gray div{
background:url(img/round_gray-right.png) right bottom no-repeat;
padding:4px;
}


Solid tooltip message box
This is a classic. A tooltip message box:


HTML is the following:

<div class="tooltips-gray">Solid message box<div></div></div>

...and CSS code is:

.tooltips-gray{
background:#444444;
color:#FFFFFF;
text-align:center;
padding-top:4px;
}
.tooltips-gray div{
background:url(img/tips_gray.png) left bottom no-repeat;
padding-top:4px;
height:18px;
}

You can yse the image you prefer to simulate the "arrow" for your tooltip.

Download the source code (HTML+CSS)

Download message box collection source code

Sponsored Links

18 comments

Sara said...

I like the way you present your post!

Anonymous said...

I agree with Sara :))

Mostly Lisa said...

Great post. High 5!!!

Hates_ said...

Great post!

Alen said...

Nice collection, thanks for sharing. You really put so much effort in your posts.
I must say I disagree with your class naming (color dependable). What if you at some point decide to change property values of class named "clean-gray" and wish to set background color to light blue?

sinan said...

where this demo url ?
please here this demo url write

Roselavy said...

As usual, one of your many great posts. Thank you for these clean and useful tuts.

dictionnaries said...

Great post, but the HTML code for icon-heart seems to have a small mistake ;-).

Ruben Zevallos Jr said...

Very nice work... I'll try it...

Best

Daniel said...

Nice post... Just a pitty about the white backgrounds in the png's. Would be more usefull if they were transparant.

JustS said...

Thank you for the tutorial and for posting the link to the sweetie package. I have been looking for a consistent set of icons for some time now.

Matt said...

Nice post. Pastel colored alert boxes with a simple icon are my favorite as well.

Here is something for discussion:

When keeping semantics in mind, do you think there is a better tag that can be used to represent an alert besides a "div" tag?

Since an alert box holds some sense of importance would a header tag such as "h4" be better?

Tom said...

Nice work, I like the way you write.

I don't like so much the extra divs for some of these alerts, but I know it's the only way using rounded corners without js :)

Jordi R Cardona said...

Thanks Antonio. This post has helped me a lot.

Tyssen said...

"When keeping semantics in mind, do you think there is a better tag that can be used to represent an alert besides a "div" tag?

Since an alert box holds some sense of importance would a header tag such as "h4" be better?"

Whether you use a heading tag or not would depend on the exact nature of the content but at the very least I'd recommend using a paragraph in the case where there only needs to be one block level element used. If you do decide to use a heading tag, the choice should be dictated by what heading tags precede it as heading tags should be used in sequence without skipping a level (e.g. h1 followed by h2 followed by h3 is correct; h1 followed by h2 followed by h4 is incorrect).

Jordi R Cardona said...

Hi,

I used this trick combined with some coding of mine and big icons, and it looks great. You can see it here:

Post

Thank you Antonio.

Paul said...

nice post - and great presentation too!

- J - said...

Thanks.
i've been looking stuff like this.

Facebook | Feeds rss About Me

Antonio Lupetti
Engineer, Pro Blogger, Mac user, Musician, Web Addicted.
ROME - ITALY antonio.lupetti@gmail.com

Subscribe feeds rss Feed RSS

Your Email (Subscribe my feed via e-mail)

Recent Entries

What's new on woork...

Twitter

What I'm doing?

Categories and Links

Categories

Browse this blog for topic...

Social Networks

My Social Networks identity...

Table of content

Did you miss something? Thake a look at my table of content.
Read more...

Advertising

How to promote a site, a product or a service on woork
Read more...

Buy a review Site reviews

Technorati Authority

Technorati
Woork authority on technorati
Add this blog to your faves
View blog authority