自適應大小的CSS圓角盒子

效果

以下是box.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>自適應大小的CSS圓角盒子</title>
<style type="text/css">
body 
{
  font-size
: 9pt;
  line-height
: 150%;
}

#box1 
{
  width
: 200px; /* 此處定義box1寬度 */
  margin
: 5px;
}

#box2 
{
  width
: 390px; /* 此處定義box2寬度 */
  margin
: 5px;
}

#box3 
{
  width
: 600px; /* 此處定義box3寬度 */
  margin
: 5px;
}

.container 
{
  float
: left;
  color
: #666;
  background
: url(rounded-right.gif) top right no-repeat;
}

.desc 
{
  margin
: 0;
  padding
: 9px 9px 0 9px;
  background
: url(rounded-left.gif) top left no-repeat;
  font-weight
: bold;
}

.link 
{
  margin
: 0;
  padding
: 0 0 0 9px;
  background
: url(rounded-left.gif) bottom left no-repeat;
}

.link em 
{
  height
: 100px; /* 此處定義box高度 */
  display
: block;
  padding
: 0 9px 9px 0;
  font-style
: normal;
  background
: url(rounded-right.gif) bottom right no-repeat;
}
</style>
</head>
<body>

<div id="box1" class="container">
  
<class="desc">自適應大小的CSS圓角盒子</p>
  
<class="link"><em>這是200×100px時的效果。<br />寬度需定義box,高度需定義link em。<br />寬度高度均不定義則爲自適應。</em></p>
</div>

<div id="box2" class="container">
  
<class="desc">自適應大小的CSS圓角盒子</p>
  
<class="link"><em>這是390×100px時的效果。<br />寬度需定義box,高度需定義link em。<br />寬度高度均不定義則爲自適應。</em></p>
</div>

<div id="box3" class="container">
  
<class="desc">自適應大小的CSS圓角盒子</p>
  
<class="link"><em>這是400×100px時的效果。<br />寬度需定義box,高度需定義link em。<br />寬度高度均不定義則爲自適應。</em></p>
</div>

</body>
</html>

 

以下是兩個用到的背景圖片,爲了避免重複,因此圖片做的越大越好。

rounded-left.gif

 rounded-left.gif

rounded-right.gif

rounded-right.gif

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章