SpeechRecognition实现浏览器端语音识别成文字搜索框输入效果代码
代码语言:html
所属分类:搜索
代码描述:SpeechRecognition实现浏览器端语音识别成文字搜索框输入效果代码
代码标签: SpeechRecognition 浏览器 语音 识别 文字 搜索框 输入
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/all.6.0.css">
<link href="https://fonts.googleapis.com/css2?family=Lato&family=Roboto&display=swap" rel="stylesheet" />
<style>
body {
align-items: center;
background-color: #eee;
display: flex;
height: 100vh;
justify-content: center;
margin: 0;
}
.a11y-hidden {
position: absolute;
left: -1000in;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: polygon(0 0, 0 0);
}
.search {
width: 90%;
max-width: 30rem;
position: relative;
}
.search .input-bar {
--active: #eee;
align-items: center;
background: #fff;
border: 2px solid #0000;
border-radius: 4rem;
box-sizing: border-box;
box-shadow: 0 1rem 2rem -1.5rem #0005;
display: inline-flex;
height: 4rem;
overflow: hidden;
transition: box-shadow 0.5s;
width: 100%;
}
.search .input-bar:focus-within {
background: #fffffc;
border: 2px solid #444;
box-shadow: 0 1rem 2rem -1.5rem #0007;
}
.search .input-bar:hover {
box-shadow: 0 1rem 2rem -1.5rem #0007;
}
.search .input-bar label {
position: absolute;
color: #888;
left: 1.625rem;
font-family: Lato, Arial, sans-serif;
font-size: 1.25rem;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
width: calc(100% - 8rem);
max-width: calc(100% - 8rem);
display: flex;
align-items: center;
z-index: 0;
}
.search .input-bar label span {
visibility: hidden;
overflow: hidden;
max-width: 0;
display: inline-block;
margin: 0 0.125rem;
transition: max-width 1s, margin 0.125s;
transition-delay: 1s;
}
.search .input-bar label span.show {
visibility: visible;
margin: 0 0.25rem;
max-width: calc(100% - 8rem);
}
.search .input-bar input {
background: transparent;
border: 0;
box-sizing: border-box;
flex: 1;
font-size: 1.25rem;
margin-left: 0.5rem;
min-width: 8rem;
outline: none;
padding-left: 1rem;
position: relative;
z-index: 1;
}
.search .input-bar input::-ms-clear, .search .input-bar input::ms-reveal {
display: none;
width: 0;
height: 0;
}
.search .input-bar input::-webkit-search-decoration, .search .input-bar input::-webkit-search-cancel-button, .search .input-bar input::-webkit-search-results-button, .search .input-bar input::-webkit-search-results-decoration {
display: none;.........完整代码请登录后点击上方下载按钮下载查看
网友评论0