html - 无法在 CSS 上正确填充

标签 html css

我正在尝试使表单看起来像这样:

enter image description here

而且每个字段之间的空间太大。我想删除那个空间。

这是我的代码:

<div class="form-style-5">

<form class="formulario" method="post">
<input type="text" name="entrada" value="Nombre">
<input type="text" name="entrada" value="Telefono">
<input type="text" name="entrada" value="E-Mail">
<select>
  <option value="Programa de interes">Programa de interes</option>
  <option value="Opcion 1">Opcion 1</option>
  <option value="Opcion 2">Opcion 2</option>
  <option value="Opcion 3">Opcion 3</option>
</select> 
<input type="checkbox" name="option1" value="Acepto">
Acepto las politicas de privacidad
<input type="submit" value="Enviar" />
</form>

</div>

CSS:

.form-style-5{
    max-width: 500px;
    padding: 0px 0px;
    background: #f4f7f8;
    margin: 0px auto;
    padding: 20px;
    background: #f4f7f8;
    border-radius: 8px;
    font-family: Georgia, "Times New Roman", Times, serif;
}
.form-style-5 fieldset{
    border: none;
}
.form-style-5 legend {
    font-size: 1.4em;
    margin-bottom: 10px;
}
.form-style-5 label {
    display: block;
    margin-bottom: 8px;
}
.form-style-5 input[type="text"],
.form-style-5 input[type="date"],
.form-style-5 input[type="datetime"],
.form-style-5 input[type="email"],
.form-style-5 input[type="number"],
.form-style-5 input[type="search"],
.form-style-5 input[type="time"],
.form-style-5 input[type="url"],
.form-style-5 textarea,
.form-style-5 select {
    font-family: Georgia, "Times New Roman", Times, serif;
    background: rgba(255,255,255,.1);
    border: none;
    border-radius: 4px;
    font-size: 16px;
    margin: 0;
    outline: 0;
    padding: 7px;
    width: 100%;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    background-color: #e8eeef;
    color:#8a97a0;
    -webkit-box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
    box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
    margin-bottom: 30px;
}
.form-style-5 input[type="text"]:focus,
.form-style-5 input[type="date"]:focus,
.form-style-5 input[type="datetime"]:focus,
.form-style-5 input[type="email"]:focus,
.form-style-5 input[type="number"]:focus,
.form-style-5 input[type="search"]:focus,
.form-style-5 input[type="time"]:focus,
.form-style-5 input[type="url"]:focus,
.form-style-5 textarea:focus,
.form-style-5 select:focus{
    background: #d2d9dd;
}
.form-style-5 select{
    -webkit-appearance: menulist-button;
    height:35px;
}
.form-style-5 .number {
    background: #1abc9c;
    color: #fff;
    height: 30px;
    width: 30px;
    display: inline-block;
    font-size: 0.8em;
    margin-right: 4px;
    line-height: 30px;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255,255,255,0.2);
    border-radius: 15px 15px 15px 0px;
}

.form-style-5 input[type="submit"],
.form-style-5 input[type="button"]
{
    position: relative;
    display: block;
    padding: 19px 39px 18px 39px;
    color: #FFF;
    margin: 0 auto;
    background: #7B7B7B;
    font-size: 18px;
    text-align: center;
    font-style: normal;
    width: 100%;
    border: 1px solid #7B7B7B;
    border-width: 1px 1px 3px;
    margin-bottom: 10px;
}
.form-style-5 input[type="submit"]:hover,
.form-style-5 input[type="button"]:hover
{
    background: #C8C8C8;
}

最佳答案

是因为.form-style-5 input[type="text"], .form-style-5 输入[type="日期"], .form-style-5 输入[type="datetime"], .form-style-5 输入[type="email"], .form-style-5 input[type="number"], .form-style-5 input[type="search"], .form-style-5 input[type="time"], .form-style-5 输入[type="url"], .form-style-5 文本区域, .form-style-5 select {margin-bottom: 30px;} 将其设置为 10px 或您喜欢的任何值。

.form-style-5{
    max-width: 500px;
    padding: 0px 0px;
    background: #f4f7f8;
    margin: 0px auto;
    padding: 20px;
    background: #f4f7f8;
    border-radius: 8px;
    font-family: Georgia, "Times New Roman", Times, serif;
}
.form-style-5 fieldset{
    border: none;
}
.form-style-5 legend {
    font-size: 1.4em;
    margin-bottom: 10px;
}
.form-style-5 label {
    display: block;
    margin-bottom: 8px;
}
.form-style-5 input[type="text"],
.form-style-5 input[type="date"],
.form-style-5 input[type="datetime"],
.form-style-5 input[type="email"],
.form-style-5 input[type="number"],
.form-style-5 input[type="search"],
.form-style-5 input[type="time"],
.form-style-5 input[type="url"],
.form-style-5 textarea,
.form-style-5 select {
    font-family: Georgia, "Times New Roman", Times, serif;
    background: rgba(255,255,255,.1);
    border: none;
    border-radius: 4px;
    font-size: 16px;
    margin: 0;
    outline: 0;
    padding: 7px;
    width: 100%;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    background-color: #e8eeef;
    color:#8a97a0;
    -webkit-box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
    box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
    margin-bottom: 10px; /*------modified-----*/
   
}
.form-style-5 input[type="text"]:focus,
.form-style-5 input[type="date"]:focus,
.form-style-5 input[type="datetime"]:focus,
.form-style-5 input[type="email"]:focus,
.form-style-5 input[type="number"]:focus,
.form-style-5 input[type="search"]:focus,
.form-style-5 input[type="time"]:focus,
.form-style-5 input[type="url"]:focus,
.form-style-5 textarea:focus,
.form-style-5 select:focus{
    background: #d2d9dd;
}
.form-style-5 select{
    -webkit-appearance: menulist-button;
    height:35px;
}
.form-style-5 .number {
    background: #1abc9c;
    color: #fff;
    height: 30px;
    width: 30px;
    display: inline-block;
    font-size: 0.8em;
    margin-right: 4px;
    line-height: 30px;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255,255,255,0.2);
    border-radius: 15px 15px 15px 0px;
}

.form-style-5 input[type="submit"],
.form-style-5 input[type="button"]
{
    position: relative;
    display: block;
    padding: 19px 39px 18px 39px;
    color: #FFF;
    margin: 0 auto;
    background: #7B7B7B;
    font-size: 18px;
    text-align: center;
    font-style: normal;
    width: 100%;
    border: 1px solid #7B7B7B;
    border-width: 1px 1px 3px;
    margin-bottom: 10px;
}
.form-style-5 input[type="submit"]:hover,
.form-style-5 input[type="button"]:hover
{
    background: #C8C8C8;
}
<div class="form-style-5">

<form class="formulario" method="post">
<input type="text" name="entrada" value="Nombre">
<input type="text" name="entrada" value="Telefono">
<input type="text" name="entrada" value="E-Mail">
 <select>
  <option value="Programa de interes">Programa de interes</option>
  <option value="Opcion 1">Opcion 1</option>
  <option value="Opcion 2">Opcion 2</option>
  <option value="Opcion 3">Opcion 3</option>
</select> 
<input type="checkbox" name="option1" value="Acepto"> Acepto las politicas de privacidad
 <input type="submit" value="Enviar" />

</form>
</div>

关于html - 无法在 CSS 上正确填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32744845/

相关文章:

javascript - 从存储在变量中的选项创建选择框

javascript - 每隔几秒从 .php 文件加载代码

java - 从 JSP 读取不同的参数到 Servlet

html - safari 的 CSS 默认字母间距与其他浏览器不同

javascript - Javascript 中的 iPhone slider - Safari 中的问题

css - Chrome 不加载 CSS 源映射?

html - 使用CSS限制div中的字符数

javascript - 制作兼容 iOS 的 Javascript 键盘的想法

html - 设计禁用 CSS 的页面

PHP - 如何在提交后隐藏表单