英文单词字母大小写在线转换工具html代码

这是一个简单而实用的在线大小写转换工具。它允许用户输入任意文本,并提供三种转换选项:转换为全大写、全小写或首字母大写。

使用这个工具非常简单快捷。用户只需要在输入框中输入想要转换的文本,选择合适的转换类型,然后点击"转换"按钮即可。转换结果会立即显示在输出框中,用户可以直接复制使用。

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>英文字母大小写在线转换工具-丢塔游戏网</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 20px;
    }
    h1 {
      text-align: center;
    }
    .container {
      max-width: 600px;
      margin: 0 auto;
    }
    .input-section,
    .output-section {
      margin-bottom: 20px;
    }
    label {
      display: block;
      margin-bottom: 5px;
    }
    textarea {
      width: 100%;
      height: 150px;
      padding: 10px;
      font-size: 16px;
      border: 1px solid #ccc;
      border-radius: 4px;
    }
    select {
      width: 100%;
      padding: 10px;
      font-size: 16px;
      border: 1px solid #ccc;
      border-radius: 4px;
    }
    button {
      display: block;
      width: 100%;
      padding: 10px;
      font-size: 16px;
      background-color: #4CAF50;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
    }
  </style>
</head>
<body>
  <h1>英文字母大小写在线转换工具</h1>
  <div class="container">
    <div class="input-section">
      <label for="input-text">输入文本:</label>
      <textarea id="input-text"></textarea>
    </div>
    <div class="conversion-section">
      <label for="conversion-type">选择转换类型:</label>
      <select id="conversion-type">
        <option value="uppercase">转换为大写</option>
        <option value="lowercase">转换为小写</option>
        <option value="titlecase">转换为首字母大写</option>
      </select>
      <button id="convert-button">转换</button>
    </div>
    <div class="output-section">
      <label for="output-text">转换结果:</label>
      <textarea id="output-text" readonly></textarea>
    </div>
  </div>

  <script>
    const inputText = document.getElementById('input-text');
    const conversionType = document.getElementById('conversion-type');
    const convertButton = document.getElementById('convert-button');
    const outputText = document.getElementById('output-text');

    convertButton.addEventListener('click', () => {
      const input = inputText.value;
      const type = conversionType.value;
      let output;

      switch (type) {
        case 'uppercase':
          output = input.toUpperCase();
          break;
        case 'lowercase':
          output = input.toLowerCase();
          break;
        case 'titlecase':
          output = input.replace(/\b\w/g, (char) => char.toUpperCase());
          break;
        default:
          output = input;
      }

      outputText.value = output;
    });
  </script>
</body>
</html>

直接保存为html代码就可以直接使用了。

这种小工具网上挺多的,自己搞一个省的去找,体验

http://diuta.com/app/zt.html

大佬有好建议意见可以分享一下
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值