javascript - 更改字符间距

标签 javascript html css char

我试图找出如何将普通字符 (ABC) 转换为全 Angular 字符 (ABC)。我找不到如何联系你们。我还没有任何 Javascript 代码。这是我的 HTML:

<html>

<head>

</head>

<body>

<link rel="stylesheet" type="text/css" href="main.css">
    <link href="https://fonts.googleapis.com/css?family=Space+Mono" rel="stylesheet">

<h1>Text convertor 2000</h1>

<textarea placeholder="Text Input" id="textarea_left" spellcheck="false"></textarea>
    <textarea placeholder="Text Output" id="textarea_right" spellcheck="false"></textarea>


</body>



</html>

和 css(即使它可能没有用):

    body { 
 background: linear-gradient(270deg, #ffa6ff, #6bffff);
  background-size: 200% 200%;
  -webkit-animation: backgroundGradient 15s linear infinite;
  -moz-animation: backgroundGradient 15s linear infinite;
  animation: backgroundGradient 15s linear infinite;
}

@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed');

h1 {
    font-family: 'Space Mono', monospace;
    font-size: 50px;
    margin-left: 640px;
    color: #631b87;
    -webkit-animation: simpleColorChange 5s ease infinite;
    -moz-animation: simpleColorChange 5s ease infinite;
    -o-animation: simpleColorChange 5s ease infinite;
    animation: simpleColorChange 5s ease infinite;
}

@-webkit-keyframes simpleColorChange {
  0% {
    color: #6c4df0
  }
  50% {
    color: #b146d4
  }
  100% {
    color: #6c4df0
  }
}

@-moz-keyframes simpleColorChange {
  0% {
    color: #6c4df0
  }
  50% {
    color: #b146d4
  }
  100% {
    color: #6c4df0
  }
}

@-o-keyframes simpleColorChange {
  0% {
    color: #6c4df0
  }
  50% {
    color: #b146d4
  }
  100% {
    color: #6c4df0
  }
}

@keyframes simpleColorChange {
   0% {
    color: #6c4df0
  }
  50% {
    color: #b146d4
  }
  100% {
    color: #6c4df0
  }
}

#textarea_left {
    margin-left: 280px;
    margin-top: 80px;
    width: 650px;
    height: 550px;
    resize: none;
    border: none;
    overflow: auto;
    outline: none;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
    font-family: 'Roboto Condensed', sans-serif;
    font-size: 25px;
}

#textarea_right {
    margin-left: 10px;
    margin-top: 80px;
    width: 650px;
    height: 550px;
    resize: none;
    border: none;
    overflow: auto;
    outline: none;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
    font-family: 'Roboto Condensed', sans-serif;
    font-size: 25px;
}

::-webkit-input-placeholder { /* Chrome/Opera/Safari */
  color: #585652;
}
::-moz-placeholder { /* Firefox 19+ */
  color: #585652;
}
:-ms-input-placeholder { /* IE 10+ */
  color: #585652;
}
:-moz-placeholder { /* Firefox 18- */
  color: #585652;
}

@-webkit-keyframes backgroundGradient {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

@-moz-keyframes backgroundGradient {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

@keyframes backgroundGradient {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

谢谢。

最佳答案

只需设置 letter-spacing CSS property 的输出 textarea到相对值(如 em )并从输入中复制值 textarea输出 textareainput 上事件:

// Get DOM references:
var input = document.getElementById("textarea_left");
var output = document.getElementById("textarea_right");

// Set up an event listener on the input textarea for when it receives input
input.addEventListener("input", function(){
  // Set the text of the output textarea to the input textarea's text
  output.value = input.value;
});
textarea { width:200px; height:200px; }
.input { font-family:Arial, Helvetica, sans-serif; }
/* Setting the letter-spacing to 1em creates a space of the height of
   one letter "M" for each character. Change it in decimals to go bigger
   or smaller as needed       */
.output { font-family:serif; letter-spacing:1em; }
<h1>Text convertor 2000</h1>

<textarea placeholder="Text Input" id="textarea_left" spellcheck="false" class="input"></textarea>
<textarea placeholder="Text Output" id="textarea_right" spellcheck="false" class="output"></textarea>

关于javascript - 更改字符间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41248921/

相关文章:

html - 全高 - Web 响应 - Twitter Bootstrap

Javascript 函数计算特定日期或时间的剩余小时数

css - CSS 新手 - 在子容器内对齐文本和照片

javascript - HTML 生成的 JavaScript 不能与其他 JavaScript 一起工作

javascript - 使用jquery轮播和wordpress,它只显示第一张图像,不显示其他图像

javascript - Polymer 从元素获取返回值并使用实例方法

javascript - 在制作Phonegap应用程序时,我应该如何添加列表项并将其保存到本地存储?

jquery - 随机页面不会加载任何 css 文件然后自动修复?

html - 需要 CSS 帮助才能使图片位于顶部

javascript - 使用 Javascript 选择特定单词?