css - html 网站首页弹出表单

标签 css forms

我创建了一个带有图像的表单,我想将其弹出到我网站的主页上。弹出表格,但我遇到的问题很少。

  1. 表格有奇怪的边缘。
  2. 我希望将提交按钮移至字段下方
  3. 我希望他们按下提交,然后将电子邮件发给我
  4. 如果他们只想关闭表单,我希望在右上角有一个 X。

这是我目前所拥有的 jsfiddle

html

<form method="post" action="mailto:youremail@youremail.com">
    <h1>
    Get a Quote
    </h1>
      <input id="name" type="text" name="name" placeholder="Name"><br>
      <input id="email" type="text" name="email" placeholder="Email"><br>
      <input id="payment" type="text" name="payment" placeholder="Avg. Monthly Payment" /><br>
  <!-- Now this is the button which closes the popup-->
<div class="panel-footer">
<button id="close" >submit</button>

CSS

form{
  background-image: url("paper.gif");
  background-repeat: no-repeat;
  margin: auto;
  position: realtive;
  width: 550px;
  height: 450px;
  font-family: Tahoma, Geneva, sans-serif;
  font-size: 14px;
  line-height: 20px;
  font-weight: bold;
  color: #09C;
  text-decoration: none;
  border-radius: 10px;
  padding: 10px;
  border: 1px solid #999;
  border: inset 1px solid #333;
  -webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
  -moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
  box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
}

input#name{
  margin-top: 200px;
}

input#name,#email, #payment {
  float: right;
  margin-bottom: 10px;
  margin-right: 15px;
  clear: both;
  width: 200px;
  display: block;
  border: 1px solid #999;
  height: 20px;
  -webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
  -moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
  box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
  padding: 2px;
}

.panel-footer{
  float:right;
}

JS

$(document).ready(function () {
    //select the POPUP FRAME and show it
    $("#popup").hide().fadeIn(1000);

    $("#close").on("click", function (e) {
        e.preventDefault();
        $("#popup").fadeOut(1000);
    });
});

最佳答案

您可以在首页放置以下代码

<div class="popupwrapper">    
    <div class="backgoround_pop">
    </div>
    <div class="newmessage">
           <div class="closebutton"> close</div>
    <form method="post" action="">
        <h1>
        Get a Quote
        </h1>
          <input id="name" type="text" name="name" placeholder="Name"><br>
          <input id="email" type="text" name="email" placeholder="Email"><br>
          <input id="payment" type="text" name="payment" placeholder="Avg. Monthly Payment" /><br>
      <!-- Now this is the button which closes the popup-->
            <div class="panel-footer">
            <input type="submit" name="submit_form" value="submit">
            </div>
        </form>
    </div>
</div>
<?php if(isset($_POST['submit_form'])){//sample email code you need to change if required
                            $name=$_POST['name'];                               
                            $email=$_POST['email'];

                            $payment=$_POST['payment'];
                            $to = 'youremail@youremail.com';
                                $subject = 'subject';
                                $headers = "From: " . strip_tags($_POST['emailadd']) . "\r\n";
                                $headers .= "Reply-To: ". strip_tags($_POST['emailadd']) . "\r\n";
                                $headers .= "CC: \r\n";
                                $headers .= "MIME-Version: 1.0\r\n";
                                $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";      
                                $message = '<html><body>';
                                $message .= '<h1>Contact Information</h1>';
                                $message .= '<table><tr><td>Name:</td><td>'.$name.'</td><tr>';

                                $message .= '<tr><td>Email:</td><td>'.$email.'</td><tr>';

                                $message .= '<tr><td>payment:</td><td>'.$payment.'</td><tr></table>';
                                $message .= '</body></html>';
                                if(mail($to, $subject, $message, $headers)){
                                    echo "<script>alert('Email Sent Successfully.');</script>";
                                }

                        }?> 

script

<script type="text/javascript">
    jQuery(document).ready(function(){
        $('.backgoround_pop').click(function(){
            $('.backgoround_pop').hide();
            $('.newmessage').hide();
        });
        $('.closebutton').click(function(){
            $('.backgoround_pop').hide();
            $('.newmessage').hide();
        });
    });
</script>

css

.closebutton {
    background: url(../images/close.png) no-repeat left;
    padding: 0 10px;
    text-transform: capitalize;
    background-position:2%
}
.backgoround_pop {
    background: #000;
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 9999;
    top: 0;
    left:0;
    opacity: 0.6;
}

关于css - html 网站首页弹出表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37177450/

相关文章:

twitter-bootstrap - bootstrap 和 flex 中的聊天气泡?

php - 使用php插入mysql

java - 以 Spring 形式为单个对象定义 POJO id

css - 背景过滤器 : Blur not working on a position absolute element

html - 看穿/不可见的白色文字阴影

javascript - 带有 jquery 的动态 css 属性(滚动)

CSS 菜单在 IE7 或更低版本中不起作用

javascript - 为什么如果条件为真,Javascript window.location 无法重定向页面?

php - 从文件中读取行并输出作为下拉列表的选项

html - 在 bootstrap 中对列重新排序以获得更大的显示