调用百度api翻译工具js

 时间:2024-10-18 00:21:35

1、新建html文档。

调用百度api翻译工具js

2、书写hmtl代码。<main class="translate"><header class="t-header"> <span class="title">当前翻译语言类型:</span> <span class="result">英语</span> <ul class="lang-panel"> <li data-type="en">英语</li> <li data-type="zh">汉语</li> <li data-type="jp">日语</li> <li data-type="kor">韩语</li> <li data-type="fra">法语</li> <li data-type="ru">俄语</li> <li data-type="de">德语</li> </ul></header><section class="content"> <textarea class="input" placeholder="请输入你要翻译的单词或语句"></textarea> <textarea class="output" placeholder="翻译结果"></textarea></section><footer class="t-footer"> <button type="button" class="transbtn">翻译</button> <button type="button" class="clear">清除</button></footer></main>

调用百度api翻译工具js

3、书写css代码。body, html, section, main, header, div, button, ul, li, span, textarea, footer { margin: 0; padding: 0; }body, html, section, main, header, div, button, ul, li, span, textarea, footer { box-sizing: border-box; }body, html, section, main, header, div, button, ul, li, textarea, footer { display: block; }main, .content, .t-header { position: relative; margin-left: auto; margin-right: auto; }.lang-panel { position: absolute; }button, textarea { outline: none; }ul, li { list-style: none; }.title, .result { font-size: 20px; line-height: 45px; color: rgb(33, 32, 32, 0.99); }body { font: 16px "微软雅黑"; overflow: hidden; height: 100%; width: 100%; background-color: #eee; }main { width: calc(100% - 60px); height: auto; border: 1px solid #ddd; box-shadow: 0 5px 10px rgba(255, 255, 255, 0.16); background-color: rgba(16, 2, 2, 0.31); padding: 10px; margin-top: 10px; }main .t-header { width: 100%; height: 45px; background-color: rgba(23, 26, 28, 0.82); border-bottom: 1px solid #f2f2f2; }.t-header .title { text-align: left; color: #e544a7; }.t-header .result { text-align: right; color: #e33535; }.lang-panel { width: calc(80% - 20px); height: 42px; top: 0; left: 200px; }.lang-panel li { width: 15%; height: 45px; line-height: 45px; text-align: center; margin-left: 16px; color: #fff; float: left; cursor: pointer; }.lang-panel li:hover { background-color: rgba(255, 255, 255, 0.21); }main .content { width: 100%; height: 400px; background-color: transparent; }.content textarea { border: 1px solid #ccc; display: inline-block; width: 49%; height: 100%; margin-left: 10px; float: left; font-size: 18px; overflow-y: auto; overflow-x: hidden; }.content textarea:focus { border: 1px solid rgba(121, 178, 214, 0.82); box-shadow: 0 0 10px rgba(121, 178, 214, 0.82); }.t-footer { width: 100%; height: 45px; border-top: 1px solid #f2f2f2; }.t-footer button { width: 60px; height: 45px; background-color: rgba(49, 196, 240, 0.92); color: #efebf2; text-align: center; line-height: 45px; border: 1px solid rgba(238, 238, 238, 0.17); margin-left: 25px; margin-right: 15px; margin-top: 5px; float: right; cursor: pointer; }.t-footer button:hover { transform: scale(1.1); }

调用百度api翻译工具js

4、书写并添加js代码。<script src="plugins/md5.js"></script><script src="js/index.js"></script>

调用百度api翻译工具js

5、代码整体结构。

调用百度api翻译工具js

6、查看效果。

调用百度api翻译工具js
  • 怎样设置图标一直显示在桌面右下角
  • 工业链条卷帘门电机种类区别
  • 如何打开360驱动大师设置页面
  • 命令提示符中Taskkill命令的用法
  • XP系统怎么换成win10系统
  • 热门搜索
    讲文明懂礼貌的手抄报 初中手抄报图片大全 有关中秋节的手抄报 爱国手抄报版面设计图 中国神话故事手抄报 美在我身边手抄报 手抄报边框设计图大全 关于环保的手抄报内容 初中安全手抄报 手抄报图片大全简单