การทำมุมให้โค้ง อย่างสวยงามด้วย CSS
posted on 16 Dec 2007 12:37 by pommatt in CSSวันนี้มาน้งเล่นที่ office คิดอยากเล่นกับ CSS ในการทำให้มุมโค้งเล่น เผื่อเอาไว้ใช้มาดูกันเลยขั้นแรก เราต้องหาภาพของมุม 4 มุมกันก่อนดังนี้
1.
2.
3.
4.
CSS Code :
body {
margin: 0;
padding: 5px;
background-color: #E4E2E4;
}
.wrapper {
width: 800px;
margin: 5px auto 5px;
}
.bl {
background: url(../images/bl.gif) 0 100% no-repeat #BCC6DC;
width: 100%;
}
.br {
background: url(../images/br.gif) 100% 100% no-repeat
}
.tl {
background: url(../images/tl.gif) 0 0 no-repeat
}
.tr {
background: url(../images/tr.gif) 100% 0 no-repeat;
padding: 10px;
min-height: 600px;
}
.clear {
font-size: 1px;
height: 1px
}
margin: 0;
padding: 5px;
background-color: #E4E2E4;
}
.wrapper {
width: 800px;
margin: 5px auto 5px;
}
.bl {
background: url(../images/bl.gif) 0 100% no-repeat #BCC6DC;
width: 100%;
}
.br {
background: url(../images/br.gif) 100% 100% no-repeat
}
.tl {
background: url(../images/tl.gif) 0 0 no-repeat
}
.tr {
background: url(../images/tr.gif) 100% 0 no-repeat;
padding: 10px;
min-height: 600px;
}
.clear {
font-size: 1px;
height: 1px
}
Code Html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Rounded corner</title>
<link rel="stylesheet" href="css/index.css"/>
</head>
<body>
<div class="wrapper">
<div class="bl">
<div class="br">
<div class="tl">
<div class="tr">
<p>pommatt !!!!</p>
</div>
</div>
</div>
</div>
<div class="clear">
</div>
</div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Rounded corner</title>
<link rel="stylesheet" href="css/index.css"/>
</head>
<body>
<div class="wrapper">
<div class="bl">
<div class="br">
<div class="tl">
<div class="tr">
<p>pommatt !!!!</p>
</div>
</div>
</div>
</div>
<div class="clear">
</div>
</div>
</body>
</html>
ผลรับ:
มัรจะยาวมาด้านล่างตลอด แต่ผมกำหนดให้สูงอย่างน้อย 600px ครับ ลองเอาไปใช้ดูนะครับ ไม่ต้องใช้ตารางให้เมื่อย hand *-*
edit @ 16 Dec 2007 12:52:13 by Pom & Ja
edit @ 16 Dec 2007 12:53:31 by Pom & Ja
เพราะทุกทีผมจะใช้ภาพเป็น 3 ชิ้น
แล้วให้มัน repeat เฉพาะช่วงกลางๆ
#1 By robocon on 2007-12-23 00:26