这是一个简单而实用的在线大小写转换工具。它允许用户输入任意文本,并提供三种转换选项:转换为全大写、全小写或首字母大写。
使用这个工具非常简单快捷。用户只需要在输入框中输入想要转换的文本,选择合适的转换类型,然后点击"转换"按钮即可。转换结果会立即显示在输出框中,用户可以直接复制使用。
点击查看代码
<!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>
最近翻译外文用到这个小工具,感觉用处还可以。
这种小工具网上挺多的,自己搞一个省的去找,体验:http://diuta.com/app/zt.html
大佬有好建议意见可以分享一下