In web designing, rounded corners play a vital role in various places. They not just look good but also allow one to create unique effects. There are many methods to achieve this effect. And, we have come up with a very simple, clean and reusable technique to create multi-sized rounded corner CSS boxes using a single image with drop shadow effects. In this short tutorial, we’ll explain you on how to achieve this effect with a simple example.

CSS Rounded Boxes

Before we proceed with this example, what we need is a basic knowledge in CSS and a solid colored background image with rounded corners. You can choose whatever color theme you want for the boxes and a drop shadow effect can be added to the image as given in this example.

In this example, we have created three CSS boxes in different sizes. To make the installation simple, we have included the CSS file in this download link. After downloading the file, upload the CSS file to your server and add the path in the shown script.


<link href="css/styles.css" type="text/css" rel="stylesheet"/> 

HTML

The HTML given here contains three div for each boxes assigned and other div for content and positioning of the boxes.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Multiple Rounded Corner CSS Boxes Using a Single Image - Example
</title>
	<link href="css/styles.css" type="text/css" rel="stylesheet"/>
	</head>
	<body>
	<!--Over All div Starts Here--> 

	<div id="box1">
	<div class="box_top"><p class="top_right"></p></div>

	<div class="content">
	<p><b>Box1</b><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Duis ornare ultricies libero. Donec fringilla, eros at dapibus
fermentum, tellus tellus auctor erat, vitae porta magna libero
sed libero.
Mauris sed leo. Aliquam aliquam.<br><br> Maecenas vestibulum.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ornare
ultricies libero.
Donec fringilla, eros at dapibus fermentum, tellus tellus auctor
erat, vitae porta magna libero sed libero.</p>
	</div>
	<div class="box_bottom"><p class="bottom_right"></p></div>
	</div>
	<div id="box2">
	<div class="box_top"><p class="top_right"></p></div>
	<div class="content">
	<p><b>Box2</b><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Duis ornare ultricies libero. Donec fringilla, eros at dapibus
fermentum, tellus tellus auctor erat, vitae porta magna libero
sed libero.
Mauris sed leo. Aliquam aliquam. Maecenas vestibulum.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Duis ornare ultricies libero. <br><br>
Donec fringilla, eros at dapibus fermentum,
tellus tellus auctor erat, vitae porta magna libero sed libero.
Mauris sed leo. Aliquam aliquam. Maecenas vestibulum.</p>
	</div>
	<div class="box_bottom"><p class="bottom_right"></p></div>
	</div>
	<div id="box3">
	<div class="box_top"><p class="top_right"></p></div>
	<div class="content">
	<p><b>Box3</b><br>
	Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Duis ornare ultricies libero.
Donec fringilla, eros at dapibus fermentum, tellus tellus auctor
erat, vitae porta magna libero sed libero.
Mauris sed leo. Aliquam aliquam. <br><br> Maecenas vestibulum.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Duis ornare ultricies libero.
Donec fringilla, eros at dapibus fermentum, tellus tellus auctor
erat, vitae porta magna libero sed libero.
Mauris sed leo. Aliquam aliquam. Maecenas vestibulum. </p>
	</div>
	<div class="box_bottom">
	<p class="bottom_right"></p></div>
	</div>
</body>
</html>

CSS

Initially some basic CSS formatting has been given for the <body> and <p> tag.


body {
	margin:0;
	padding:0;
	font:12px arial;
}
p {
	margin:0;
	padding:0;
}

Here for Box1, the background image is applied in six positions such as left top, right top, left bottom, right bottom and in middle of left and right. After positioning, width and height for the box should be set based on the content and layout being used. Repeat the same for the other two boxes.


/* Box 1 */

#box1 {
	background:url(../images/box_bg.jpg) repeat-y;
	float:left;
	width:500px
}
#box1 .box_top {
	background:url(../images/box_bg.jpg) no-repeat left top;
	float:left;
	width:500px;
	height:30px;
	margin:0;
	padding:0;
}
#box1 .box_top p.top_right {
	background:url(../images/box_bg.jpg) no-repeat right top;
	float:right;
	width:30px;
	height:30px;
	margin:0;
	padding:0;
}
#box1 .content {
	background:url(../images/box_bg.jpg) repeat-y right -30px;
	float:left;
	margin:0 0 0 20px;
	padding-right:20px;
	width:460px;
}
#box1 .box_bottom {
	background:url(../images/box_bg.jpg) no-repeat left bottom;
	float:left;
	width:500px;
	height:30px;
	margin:0;
	padding:0;
}
#box1 .box_bottom p.bottom_right {
	background:url(../images/box_bg.jpg) no-repeat right bottom;
	float:right;
	width:20px;
	height:30px;
	margin:0;
	padding:0;
}

This single image technique is applicable for any number of rounded corner CSS boxes with varying sizes and colors.

The script used in this tutorial has been shortened to explain, so for implementation use the source provided in the download zip file. If you have any doubts in implementing this functionality, drop in your queries in the Comments section.

Dot Com Infoway has created an example for multiple rounded corner CSS boxes using a single image with a drop shadow effect. To view this example please click here.

Popularity: 11%

Leave a Reply:

No Responses to “Multiple Rounded Corner CSS Boxes Using a Single Image”

Leave a Reply:

Name (required):
Email Address (required, not published) :
Website :
Comment (required):

Contact Us :

Dot Com Infoway, a CMMI Level 3 multinational information technology company, is a pioneer in delivering software development, mobile application and Internet marketing solutions and technologies to businesses. With offices in India, the United States and Netherlands, DCI is positioned to become a leader in delivering advanced IT services for your business.

For more information, email ask@dotcominfoway.com or visit our Contact Page.

Follow Us :

Dot Com Infoway

Tailored to meet international standards and client expectations, our methodology ensures proper risk management, seamless work flow and deadline-oriented development. It has built-in processes to monitor stringent adherence to quality, consistency in performance and accomplishment of project milestones. Our well-defined and flexible business model is a result of our deep industry intelligence and vast experience. Adhering to industry standards, our business model facilitates enterprises to get the best-of-breed solutions at affordable prices and top-notch quality.

Our privacy policy explains how we use and protect any information that you provide when you use our website. With high standards of security, we ensure that your valuable data is protected from misuse, loss or any external amendment.