【发布时间】:2020-04-25 02:56:40
【问题描述】:
我一直致力于构建一个网站,其中包含一些基本功能,如果需要,我可以在以后添加这些功能。
我希望用户能够在“在此处输入...”输入框中输入文本,当他们按下 Enter 键时,根据他们刚刚输入的命令在他们的网站上添加一个新行。
例如,如果他们输入“帮助”,它会添加几行新行来解释网站的功能和一些开始的命令。我的想法是继续向其中添加命令,这需要一些可扩展性。我的网站 + 输入框按我的意愿工作。
.headTag {
background-color: lightgrey;
display: inline-block;
width: 100%;
height: 26px;
}
.topPageTitle {
color: black;
font-size: 18px;
float: left;
background-color: lightgrey;
margin-top: 0px;
}
.mainPageText {
color: black;
font-size: 18px;
float: right;
margin-right:10px;
margin-top: 0px;
}
.userInput {
width: 100%;
position: absolute;
bottom: 10px;
}
.mainWindow {
margin-top: 24px;
font-family: typewriter;
font-size: 18px;
color: green;
width: 100%
}
.mainWindow p {
margin-top: -18px;
}
input[type=text] {
width: 100%;
border: none;
background-color: black;
font-size: 18px;
font-family: typewriter;
color: green;
outline: none !important;
}
@font-face {
font-family: typewriter;
src: url('../assets/typewriter.ttf');
}
body {
background-color: black;
font-family: typewriter;
color: lightgrey;
background:#000;
}
.easyMenu {
position: absolute;
bottom: 5px;
font-family: typewriter;
font-size: 18px;
width: 100%;
}
.easyMenu a {
color: lightgrey;
width: 24.5%;
display:inline-block;
}
.easyMenu a:hover {
color: black;
background-color: lightgrey;
}
<html>
<head>
<link rel="stylesheet" type="text/css" href="stylesheets/style.css">
</head>
<body>
<div class="headTag">
<p class="mainPageText">13.04.2020</p>
</div>
<div class="mainWindow">
<p>system>: Welcome to the Website.</p>
<p>system>: If you are stuck or don't know what to do type "Help"</p>
</div>
<div class="userInput">
<form>
<input type="text" autocomplete="off" spellcheck="false" id="fname" name="fname" value ="Type here..." onfocus="if(this.value==this.defaultValue)this.value=''" onblur="if(this.value=='')this.value=this.defaultValue">
</form>
</div>
<div class="easyMenu">
<a>>: Back</a>
<a>>: Create Private Chat</a>
<a>>: Join Private Chat</a>
<a>>: Information</a>
</div>
</body>
</html>
理想情况下,我想坚持使用纯 HTML+CSS,但如果需要 JS,我很乐意使用它。我也对使用 Python WSGI 执行此操作的想法持开放态度,但不确定是否开始此操作。
非常感谢任何帮助/建议。
亲切的问候 詹姆斯
【问题讨论】:
-
您需要 JavaScript 在他们按下 Enter 时采取行动。
-
使用
placeholder属性在输入字段中显示一个临时字符串。
标签: javascript python php html css