html弹框式Form表单输入

html弹框式Form表单输入

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <style>
body{
  margin: 0,0,0,0;
  overflow: hidden;
}
.main{
  margin: 0,0,0,0;
  overflow: hidden;
}
button{
  width:200px;
  height:60px;
  font-size: 25px;
  background-color:#21bf73 ;
  color: white;
  border:none;
  border-radius: 10px;
  
  
}
.form_1{
  width:400px;
  height:300px;
  border:3px solid #f8f8f8;
  visibility: hidden;
  position: absolute;
  z-index: 999;
  opacity: 1;
  overflow: hidden;
  background-color: white;
  text-align: center;
  margin-top: 10%;
  margin-left: 35%;
  border-radius: 10px;
}
.open{
  visibility: visible;
  opacity: 1;
}
.input_1{
  margin-top: 15px;
  width:100%;
  height:40px;
  
}
input{
  width:280px;
  height:30px;
  border-radius: 5px;
  border:1px solid  #e5dfdf;
}
.input_1 .login_logo{
  text-align: left;
  font-size: 20px;
  font-weight: 300;
  padding-left: 30px;
  float: left;
}
.input_1 .close{
  width:20px;
  height:20px;
  color:#5d5d5d;
  text-align: center;
  line-height: 20px;
  border:1px solid  #5d5d5d;
  border-radius: 50%;
  float: right;
  padding-top: 0px;
  margin-right: 10px;
  font-size: 12px;
}
.input_1 .close:hover{
  cursor:pointer;
}
hr{
  background-color: #F8F8F8;
}

.input_1 .submit_1{
  border:2px solid #f88020;
  height:40px;
  background-color: white;
}
.input_1 .submit_1:hover{
  background-color: #f88020;
  color:white;
}
.test{
  overflow: hidden;
}
#btn_2{
  background-color: #F88020;
}
.dialog{
  width:300px;
  height:120px;
  border:2px solid #46b3e6;
  overflow: hidden;
  visibility: hidden;
  z-index: 999;
  overflow: hidden;
  opacity: 1;
  position: absolute;
  background-color: white;
  margin-top: 5%;
  margin-left: 40%;
}
.dialog .title{
  text-align: center;
  font-size: 20px;
  font-weight: 300;
  margin-top: 28px;
  margin-bottom: 25px;
}
.dialog  .btn_2{
  width:50%;
  height:40px;
  float:left;
  background-color: #dff6f0;
  line-height: 40px;
  color: black;
  text-align: center;
  margin-bottom: 0px;
}
.dialog .btn_2:hover{
  background-color:#F88020 ;
}
.dialog  .close_1{
  overflow: hidden;
  width:50%;
  height:40px;
  background-color: red;
  margin-bottom: 0px;
  line-height: 40px;
  color: white;
  text-align: center;
}
.dialog .close_1:hover{
  background-color: #f4f4f4;
  color:red;
  cursor: cell;
}


    </style>
  </head>
  <body>
    <div class="main">
    <button id="btn_1"> 用户登录</button>
    <div class="form_1">
      <form >
      <div class="input_1"><div class="login_logo">用户登录</div><div class="close">X</div></div>
      <hr>
      <div class="input_1"><input type="text" name="user" placeholder=" 用户名"></div>
      <div class="input_1"><input type="password" name="password" placeholder=" 密码"></div>
      <div class="input_1"><input class="submit_1" type="submit" value="提 交"></div>
      </form>
    </div>
    </div>
    <button id="btn_2"> 弹 框 提 示</button>

    <div class="dialog">
      <div class="title">xxxxxxxx 确定吗?</div>
      <div class="btn_2">确定</div>
      <div class="close_1">取消</div>
      
    </div>
  </body>


  <Script>
    window.onload=function(){
      var btn_1=document.getElementById("btn_1");
      var btn_2=document.getElementById("btn_2");
      var close=document.getElementsByClassName("close");
      var close_1=document.getElementsByClassName("close_1");
      var dialog=document.getElementsByClassName("dialog");
      var form_1=document.getElementsByClassName("form_1");
      btn_1.addEventListener('click',function(){
        form_1[0].className="form_1 open";  
      })
      close[0].addEventListener('click',function(){
        form_1[0].className="form_1";
      })
      btn_2.addEventListener('click',function(){
        dialog[0].style.visibility='visible';
      })
      close_1[0].addEventListener('click',function(){
        dialog[0].style.visibility='hidden';
      })  
  }

  </Script>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用 vue-element 的 Dialog 组件和 Form 组件相结合来实现框和的组合。具体步骤如下: 1. 在框中使用 Form 组件,将项放在 Form 组件中。 2. 在框中添加确定和取消按钮,确定按钮绑定一个方法,用来提交数据;取消按钮绑定一个方法,用来关闭框。 3. 在确定按钮的方法中,调用 Form 组件的 validate 方法来校验数据,如果校验通过则提交数据并关闭框,否则不做任何操作。 示例代码如下: ```html <template> <el-dialog :visible.sync="dialogVisible" title="框标题"> <el-form :model="form" :rules="rules" ref="form"> <el-form-item label="项1" prop="item1"> <el-input v-model="form.item1"></el-input> </el-form-item> <el-form-item label="项2" prop="item2"> <el-input v-model="form.item2"></el-input> </el-form-item> </el-form> <div slot="footer"> <el-button @click="dialogVisible = false">取消</el-button> <el-button type="primary" @click="submitForm">确定</el-button> </div> </el-dialog> </template> <script> export default { data() { return { dialogVisible: false, form: { item1: '', item2: '' }, rules: { item1: [{ required: true, message: '请输入项1', trigger: 'blur' }], item2: [{ required: true, message: '请输入项2', trigger: 'blur' }] } } }, methods: { submitForm() { this.$refs.form.validate(valid => { if (valid) { // 提交数据 // ... // 关闭框 this.dialogVisible = false } }) } } } </script> ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值