트렌드나인

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

· 2007-03-05 (월) 13:24:13 · 4328
<!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,315
08-03-14 조회 3,203
08-03-08 조회 3,022
08-03-06 조회 2,994
08-03-03 조회 4,285
08-02-20 조회 2,972
08-02-15 조회 3,886
08-02-11 조회 5,043
08-02-09 조회 5,755
08-02-05 조회 3,816
08-01-14 조회 6,627
08-01-11 조회 7,060
08-01-04 조회 1.1만
07-12-10 조회 4,963
07-12-10 조회 3,833
07-12-04 조회 3,371
07-11-29 조회 3,546
07-11-27 조회 3,902
07-11-23 조회 4,502
07-11-23 조회 4,232
07-11-13 조회 4,362
07-10-19 조회 4,821
07-10-17 조회 5,875
07-10-03 조회 4,947
07-10-02 조회 8,797
07-10-02 조회 4,454
07-09-09 조회 3,419
07-07-29 조회 4,309
07-07-28 조회 4,535
07-07-26 조회 4,439
07-06-19 조회 1.1만
07-06-17 조회 3,604
07-06-15 조회 4,103
07-05-31 조회 3,159
07-05-09 조회 5,316
07-05-04 조회 3,163
07-05-04 조회 3,510
07-04-28 조회 6,408
07-04-26 조회 4,653
07-04-14 조회 5,297
07-04-13 조회 3,713
07-04-12 조회 5,907
07-03-27 조회 3,846
07-03-19 조회 3,538
07-03-13 조회 4,618
07-03-07 조회 4,770
07-03-07 조회 3,282
07-02-25 조회 3,638
07-02-21 조회 4,530
07-02-18 조회 5,048
07-02-12 조회 3,393
07-02-02 조회 4,508
07-01-28 조회 6,121
07-01-27 조회 5,630
07-01-25 조회 3,994
07-01-21 조회 4,628
07-01-19 조회 6,571
07-01-19 조회 8,030
07-01-13 조회 3,486
07-01-09 조회 5,124
06-12-27 조회 3,527
06-11-24 조회 3,646
06-11-18 조회 4,165
06-10-17 조회 5,485
06-10-01 조회 4,407
06-09-26 조회 4,289
06-09-25 조회 4,609
06-09-25 조회 4,317
06-09-22 조회 4,850
06-09-22 조회 3,623
06-09-22 조회 4,451
06-09-13 조회 5,282
06-08-27 조회 4,884
06-08-26 조회 6,265
06-08-26 조회 5,569
06-08-23 조회 5,064
06-07-28 조회 7,166
06-07-24 조회 4,622
06-07-23 조회 5,402
06-07-21 조회 5,162
06-07-19 조회 3,045
06-07-19 조회 2,956
06-07-11 조회 3,616
06-07-11 조회 3,909
06-07-11 조회 4,477
06-07-11 조회 4,942
06-07-11 조회 3,567
06-07-11 조회 9,190
06-07-11 조회 4,052
06-07-11 조회 3,282
06-07-11 조회 3,331
06-07-11 조회 3,259
06-07-11 조회 3,062
06-07-07 조회 4,106
06-06-25 조회 4,455
06-06-15 조회 4,448
06-06-14 조회 4,940
06-06-11 조회 3,522
06-06-10 조회 3,903
06-06-09 조회 3,489