文字の拡大、縮小

文字の拡大、縮小

  • 文字小ボタン
  • 文字中ボタン
  • 文字大ボタン
JavaScript ▼
            //フォントサイズ変更の関数定義
            var font = 80;
            window.onload = function (){
              document.getElementById('fontS').onclick = function(){
                fontChg("down");
              };
              document.getElementById('fontM').onclick = function(){
                fontChg("");
              };
              document.getElementById('fontL').onclick = function(){
                fontChg("up");
              };
            }
            function fontChg(mode) {
            
              if(mode == "down") {
                font -= 10;
              } else if(mode == "up") {
                font += 10;
              } else {
                font = 80;
              }
            
              document.getElementById("indexBody").style.fontSize = font + "%";
            }
             
          
HTML ▼
            <ul>
              <li id="fontS"><img src="fontS.gif" 
              alt="文字小ボタン" width="40" height="40" /></li>
              <li id="fontM"><img src="fontM.gif" 
              alt="文字中ボタン" width="40" height="40" /></li>
              <li id="fontL"><img src="fontL.gif" 
              alt="文字大ボタン" width="40" height="40" /></li>
            </ul>