트렌드나인

[스크립트] 이미지 없는 둥글게 테두리 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건
+
제목 글쓴이 날짜 조회
07-04-22 조회 2,950
07-04-22 조회 2,564
07-04-22 조회 2,391
07-04-22 조회 2,307
07-04-21 조회 2,375
07-04-21 조회 2,704
07-04-21 조회 2,057
07-04-21 조회 2,480
07-04-21 조회 2,319
07-04-21 조회 2,394
07-04-20 조회 4,202
07-04-20 조회 2,116
07-04-20 조회 2,338
07-04-20 조회 3,370
07-04-20 조회 3,470
07-04-20 조회 2,492
07-04-20 조회 3,093
07-04-20 조회 2,355
07-04-19 조회 3,698
07-04-18 조회 7,778
07-04-18 조회 4,982
07-04-18 조회 3,387
07-04-17 조회 7,538
07-04-17 조회 3,802
07-04-17 조회 3,846
07-04-17 조회 3,289
07-04-16 조회 3,299
07-04-16 조회 3,285
07-04-16 조회 5,147
07-04-15 조회 5,204
07-04-15 조회 6,274
07-04-14 조회 5,368
07-04-13 조회 3,797
07-04-13 조회 3,111
07-04-13 조회 4,073
07-04-13 조회 3,936
07-04-13 조회 3,430
07-04-12 조회 6,624
07-04-12 조회 5,964
07-04-12 조회 5,031
07-04-12 조회 4,637
07-04-12 조회 3,312
07-04-12 조회 3,340
07-04-12 조회 4,858
07-04-11 조회 3,477
07-04-11 조회 3,686
07-04-11 조회 2,932
07-04-11 조회 5,708
07-04-11 조회 3,333
07-04-11 조회 3,471
07-04-11 조회 5,224
07-04-08 조회 5,208
07-04-07 조회 3,301
07-04-05 조회 3,983
07-04-05 조회 6,353
07-04-04 조회 3,588
07-04-04 조회 4,158
07-04-02 조회 9,812
07-03-31 조회 3,192
07-03-31 조회 4,166
07-03-30 조회 3,785
07-03-30 조회 4,173
07-03-29 조회 3,631
07-03-29 조회 3,683
07-03-27 조회 3,912
07-03-27 조회 5,138
07-03-27 조회 3,838
07-03-26 조회 3,896
07-03-24 조회 4,413
07-03-24 조회 4,041
07-03-23 조회 3,284
07-03-22 조회 3,702
07-03-21 조회 3,723
07-03-21 조회 5,226
07-03-21 조회 5,963
07-03-20 조회 3,551
07-03-20 조회 3,732
07-03-20 조회 3,634
07-03-20 조회 4,998
07-03-19 조회 3,613
07-03-19 조회 3,535
07-03-18 조회 2,867
07-03-18 조회 3,159
07-03-18 조회 3,987
07-03-18 조회 4,734
07-03-17 조회 4,229
07-03-16 조회 4,124
07-03-16 조회 3,164
07-03-15 조회 5,287
07-03-15 조회 3,363
07-03-13 조회 5,393
07-03-13 조회 3,697
07-03-13 조회 3,580
07-03-13 조회 4,682
07-03-13 조회 3,422
07-03-13 조회 3,318
07-03-12 조회 4,459
07-03-11 조회 5,137
07-03-11 조회 3,371
07-03-11 조회 3,545