트렌드나인

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

· 2007-03-05 (월) 13:24:13 · 4341
<!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건
+
제목 글쓴이 날짜 조회
08-04-17 조회 4,331
08-03-14 조회 3,213
08-03-08 조회 3,032
08-03-06 조회 3,008
08-03-03 조회 4,297
08-02-20 조회 2,981
08-02-15 조회 3,900
08-02-11 조회 5,053
08-02-09 조회 5,793
08-02-05 조회 3,826
08-01-14 조회 6,638
08-01-11 조회 7,069
08-01-04 조회 1.1만
07-12-10 조회 4,974
07-12-10 조회 3,840
07-12-04 조회 3,381
07-11-29 조회 3,555
07-11-27 조회 3,911
07-11-23 조회 4,508
07-11-23 조회 4,243
07-11-13 조회 4,367
07-10-19 조회 4,832
07-10-17 조회 5,882
07-10-03 조회 5,042
07-10-02 조회 8,809
07-10-02 조회 4,464
07-09-09 조회 3,438
07-07-29 조회 4,323
07-07-28 조회 4,541
07-07-26 조회 4,449
07-06-19 조회 1.1만
07-06-17 조회 3,615
07-06-15 조회 4,110
07-05-31 조회 3,172
07-05-09 조회 5,325
07-05-04 조회 3,177
07-05-04 조회 3,519
07-04-28 조회 6,417
07-04-26 조회 4,665
07-04-14 조회 5,311
07-04-13 조회 3,724
07-04-12 조회 5,915
07-03-27 조회 3,858
07-03-19 조회 3,560
07-03-13 조회 4,629
07-03-07 조회 4,779
07-03-07 조회 3,289
07-02-25 조회 3,648
07-02-21 조회 4,538
07-02-18 조회 5,063
07-02-12 조회 3,408
07-02-02 조회 4,520
07-01-28 조회 6,133
07-01-27 조회 5,645
07-01-25 조회 4,004
07-01-21 조회 4,639
07-01-19 조회 6,581
07-01-19 조회 8,039
07-01-13 조회 3,498
07-01-09 조회 5,137
06-12-27 조회 3,535
06-11-24 조회 3,660
06-11-18 조회 4,177
06-10-17 조회 5,498
06-10-01 조회 4,417
06-09-26 조회 4,303
06-09-25 조회 4,623
06-09-25 조회 4,333
06-09-22 조회 4,862
06-09-22 조회 3,635
06-09-22 조회 4,466
06-09-13 조회 5,294
06-08-27 조회 4,896
06-08-26 조회 6,272
06-08-26 조회 5,578
06-08-23 조회 5,076
06-07-28 조회 7,176
06-07-24 조회 4,635
06-07-23 조회 5,415
06-07-21 조회 5,173
06-07-19 조회 3,056
06-07-19 조회 2,975
06-07-11 조회 3,627
06-07-11 조회 3,919
06-07-11 조회 4,495
06-07-11 조회 4,958
06-07-11 조회 3,578
06-07-11 조회 9,199
06-07-11 조회 4,058
06-07-11 조회 3,289
06-07-11 조회 3,339
06-07-11 조회 3,273
06-07-11 조회 3,076
06-07-07 조회 4,119
06-06-25 조회 4,466
06-06-15 조회 4,461
06-06-14 조회 4,944
06-06-11 조회 3,534
06-06-10 조회 3,918
06-06-09 조회 3,499