트렌드나인

[스크립트] 이미지 없는 둥글게 테두리 DIV

<!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=utf-8" />
<title>이미지 없이 라운딩 박스 + 보더 표현하기!</title>
<style>
 * {font-size:12px;}
 #test {padding:3px;}
</style>

</head>

<body>


<div id='test'>이미지 없이 라운딩 박스 + 보더 표현하기!</div>


<script>

function round(elm, bgcolor, border, mode) {
  var top = document.createElement('div'); top.style.cssText = 'height:5px';
  var bottom = document.createElement('div');bottom.style.cssText = 'height:5px';
  var temp = document.createElement('div'); temp.setAttribute('id', 'template');
  var border2 = (border) ? ";border-left:2px solid "+border+";border-right:2px solid "+border : "";
  var border1 = (border) ? ";border-left:1px solid "+border+";border-right:1px solid "+border : "";
  var bgcolor2 = (bgcolor) ? ";background:"+bgcolor : "";
  var bgcolor1 = (border) ? ";background:" + border : (bgcolor) ? ";background:" + bgcolor : "";

  var top_r = new Array(), bottom_r =new Array;
  var box = elm.cloneNode(true)
  for (i=1; i < 5 ;i++ )
  { top_r[i] = document.createElement('div')}

  top_r[1].style.cssText = 'margin:0px 5px;height:1px' + bgcolor1 ;
  top_r[2].style.cssText = 'margin:0px 3px;height:1px' + border2 + bgcolor2;
  top_r[3].style.cssText = 'margin:0px 2px;height:1px' + border1 + bgcolor2;
  top_r[4].style.cssText = 'margin:0px 1px;height:2px' + border1 + bgcolor2;

 
  for (i=1; i < 5 ;i++ ) {
    if (mode!='bottom') { top.appendChild(top_r[i]);temp.appendChild(top); }
    bottom_r[i] = top_r[i].cloneNode(true);
  }

  temp.appendChild(box);
  box.style.cssText =  border1 + bgcolor2;
  temp.appendChild(bottom);

  if (mode!='top') {
    for (i=4; i > 0 ;i-- ) {
      bottom.appendChild(bottom_r[i]);
    }
  }

  elm.parentNode.replaceChild(temp, elm);

}

</script>
<p>
<a href="#" onclick="round(document.getElementById('test'),'#f0f0f0','#c0c0c0')">배경+테두리</a> <br />

<a href="#" onclick="round(document.getElementById('test'),'#eeeeee')">배경만</a> <br />


<a href="javascript:window.location.reload()">원상태로</a> <br />
</p>
</body>
</html>
[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
10-09-25 조회 2,755
10-09-19 조회 2,792
10-09-15 조회 2,806
10-09-15 조회 4,210
10-09-15 조회 3,446
10-09-15 조회 2,537
10-09-07 조회 3,656
10-08-27 조회 4,111
10-06-11 조회 4,293
10-05-31 조회 2,540
10-02-27 조회 5,053
10-02-09 조회 3,798
09-10-10 조회 7,390
09-03-19 조회 3,244
09-02-09 조회 3,517
09-02-09 조회 4,567
08-11-01 조회 2,950
08-09-29 조회 4,603
08-09-26 조회 3,537
08-09-26 조회 3,610
08-09-26 조회 2,746
08-09-26 조회 3,791
08-09-26 조회 3,518
08-09-26 조회 4,288
08-09-18 조회 3,633
08-09-09 조회 3,267
08-08-28 조회 2,808
08-07-06 조회 3,577
08-05-21 조회 4,735
08-05-13 조회 4,582
08-04-17 조회 4,951
08-02-19 조회 3,566
08-01-18 조회 3,895
08-01-10 조회 3,856
07-10-22 조회 3,691
07-10-09 조회 4,361
07-10-03 조회 3,566
07-07-06 조회 4,241
07-07-06 조회 4,455
07-07-06 조회 4,071
07-06-28 조회 3,602
07-06-05 조회 3,615
07-06-05 조회 4,162
07-05-30 조회 3,328
07-05-02 조회 3,708
07-04-15 조회 5,191
07-04-11 조회 3,670
07-04-05 조회 3,975
07-03-31 조회 3,184
07-03-31 조회 4,157
07-03-30 조회 3,772
07-03-24 조회 4,031
07-03-22 조회 3,693
07-03-12 조회 4,447
07-02-16 조회 3,316
07-02-14 조회 5,198
07-02-10 조회 4,042
07-02-09 조회 4,419
07-01-19 조회 4,090
07-01-16 조회 5,025
06-12-16 조회 5,889
06-11-30 조회 3,638
06-11-25 조회 3,756
06-10-15 조회 5,107
06-09-26 조회 5,343
06-09-26 조회 5,463
06-09-22 조회 4,323
06-09-21 조회 3,570
06-09-21 조회 3,673
06-09-02 조회 3,511
06-08-08 조회 5,150
06-07-20 조회 3,777
06-07-17 조회 3,400
06-07-13 조회 4,221
06-07-11 조회 3,515
06-07-11 조회 3,516
06-07-11 조회 3,877
06-06-29 조회 6,117
06-06-19 조회 6,491
06-06-02 조회 3,553
06-05-24 조회 5,028
06-05-14 조회 7,818
06-05-08 조회 3,938
06-02-02 조회 5,489
05-12-16 조회 4,565
05-12-05 조회 5,197
05-06-28 조회 4,156
05-04-11 조회 4,111
05-04-11 조회 4,287
05-04-11 조회 3,349
05-03-13 조회 3,262
05-03-12 조회 4,322
04-12-08 조회 7,816
04-12-01 조회 5,222
04-11-28 조회 3,407
04-11-28 조회 3,241
04-08-05 조회 5,662
04-08-05 조회 5,007
04-08-05 조회 5,623