所以我是html和css的新手,我得到了它的要点,但有一件事我一直坚持下去,而且当我有标签的时候,从Iäve读到的这是一件坏事,最好只使用你的style.css文件。


我正在尝试创建4个表单,firstname&姓氏,电子邮件,电话号码和一个带有消息的框,然后在底部添加一个按钮。


我从这里得到了示例,并认为我将从中学习
来源:
https://www.w3schools.com/css/tryit.asp?filename= trycss_form_icon
如何在我的CSS中添加我的标签,以便我可以用它来创建更多表单。

&#xA ; <!DOCTYPE html>
< html>
 < HEAD> 
 <标题> ComputerFix< /标题> 
 < link rel =“stylesheet”type =“text / css”href =“style.css”>
 < meta name =“viewport”content =“width = device-width,initial-scale = 1.0”>
 < meta charset =“UTF-8”>

 <风格> 
输入[type = text] {
顶部:30%;
左:20%;
 position:absolute;
宽度:20%;
 box-sizing:border-box;
 border:2px solid #ccc;
 border-radius:4px;
 font-size:16px;
 background-color:white;
背景位置:10px 10px; 
 background-repeat:no-repeat;
填充:12px 20px 12px 15px;
 }

 < /风格>
 < /头> 

 < body class =“StandardBackground”> 
 < div id =“navbar”> 
 < UL> 
 < li>< a href =“index.html”>主页< / a>< / li> 
 < li>< a href =“about.html”>关于< / a>< / li> 
 < li>< a href =“information.html”>信息< / a>< / li>
 < li>< a href =“contact.html”>联系< / a>< / li>
 < li>< a href =“download.html”>下载< / a>< / li>
 < / UL> 
 < / DIV> 

 <形式>
 < input type =“text”name =“search”placeholder =“Fist and Lastname”>
 < /形式>

 < /体>
< / HTML>
 代码>


答案 0 :(得分:1)
只需将样式粘贴到css文件中,这也可以。
input[type=text] {
top: 30%;
left: 20%;
position: absolute;
width: 20%;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 15px;
}
但是如果您想要创建表单,可能需要阅读w3 forms以下是一些带有CSS的示例。如果你的新手,这可能会令人困惑,这就是为什么你可能想要谷歌一些形式的教程和学习。
来自Here的示例: -
.form-style-6 {
font: 95% Arial, Helvetica, sans-serif;
max-width: 400px;
margin: 10px auto;
padding: 16px;
background: #F7F7F7;
}
.form-style-6 h1 {
background: #43D1AF;
padding: 20px 0;
font-size: 140%;
font-weight: 300;
text-align: center;
color: #fff;
margin: -16px -16px 16px -16px;
}
.form-style-6 input[type="text"],
.form-style-6 input[type="date"],
.form-style-6 input[type="datetime"],
.form-style-6 input[type="email"],
.form-style-6 input[type="number"],
.form-style-6 input[type="search"],
.form-style-6 input[type="time"],
.form-style-6 input[type="url"],
.form-style-6 textarea,
.form-style-6 select {
-webkit-transition: all 0.30s ease-in-out;
-moz-transition: all 0.30s ease-in-out;
-ms-transition: all 0.30s ease-in-out;
-o-transition: all 0.30s ease-in-out;
outline: none;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
width: 100%;
background: #fff;
margin-bottom: 4%;
border: 1px solid #ccc;
padding: 3%;
color: #555;
font: 95% Arial, Helvetica, sans-serif;
}
.form-style-6 input[type="text"]:focus,
.form-style-6 input[type="date"]:focus,
.form-style-6 input[type="datetime"]:focus,
.form-style-6 input[type="email"]:focus,
.form-style-6 input[type="number"]:focus,
.form-style-6 input[type="search"]:focus,
.form-style-6 input[type="time"]:focus,
.form-style-6 input[type="url"]:focus,
.form-style-6 textarea:focus,
.form-style-6 select:focus {
box-shadow: 0 0 5px #43D1AF;
padding: 3%;
border: 1px solid #43D1AF;
}
.form-style-6 input[type="submit"],
.form-style-6 input[type="button"] {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
width: 100%;
padding: 3%;
background: #43D1AF;
border-bottom: 2px solid #30C29E;
border-top-style: none;
border-right-style: none;
border-left-style: none;
color: #fff;
}
.form-style-6 input[type="submit"]:hover,
.form-style-6 input[type="button"]:hover {
background: #2EBC99;
}

<div class="form-style-6">
<h1>Contact Us</h1>
<form>
<input type="text" name="field1" placeholder="Your Name" />
<input type="email" name="field2" placeholder="Email Address" />
<textarea name="field3" placeholder="Type your Message"></textarea>
<input type="submit" value="Send" />
</form>
</div>
&#13;
Google是你的朋友。总是希望回答你的问题。