学做网站培训课程介绍

当前位置:

网站全站隐藏式在线询盘表单(带自动弹出)

网站全站隐藏式在线询盘表单,在网页的右下角,自适应手机端,当网页打开8秒后,会自动弹出询盘表单,如果用户点击之后,就不再弹出。用户可以点击展开与隐藏。

隐藏时:

展开时:

实现代码:

<!--询盘弹窗-->
<style>
.tjdiv input{width:100%;box-sizing: border-box;background:#fff;padding:10px;border:1px solid #ddd;border-radius:0px}
.tjdiv textarea{width:100%;background:#fff;box-sizing: border-box;padding:10px;border:1px solid #ddd;border-radius:0px;min-height:100px;}
#tjbtnn{width:40%;text-align:center;background:#000;color:#fff;border-radius:0px;display:block;cursor:pointer;}
.xss{position:absolute;top:10px;right:10px;font-size:13px;cursor:pointer;}
.content-wrap-live-main {position: fixed;bottom: 0px;right: 0px;z-index: 999999;max-width: 337px;}
.content-wrap-live.form {border-radius: 0px;box-shadow: 0 4px 20px rgba(0,0,0,0.15);overflow: hidden;background: white;}
.content-wrap-live-main{width:337px;position:fixed;right:0;bottom:0;z-index:999999}
.content-wrap-live{width:100%;background:#fff;}
.content-wrap-live h3.titles{position:relative;background: #013e5a;height: 55px;line-height: 55px;color: #fff;margin: 0;padding: 0;font-size: 16px;padding: 0 20px;font-weight: normal;cursor: pointer;}
.content-wrap-live .titles em {font-style: normal;font-weight: 600;}
.content-wrap-live .titles svg {transition: transform 0.4s ease;position:absolute;top:30%;right:20px}
.content-wrap-live .layout6s {max-height: 0;overflow: hidden;transition: max-height 0.8s ease-out;background: white;}
.content-wrap-live .expanded {max-height: 500px;}
.content-wrap-live .rotated {transform: rotate(180deg);}
.content-wrap-live .form-container {padding: 1.5rem;}
.content-wrap-live .form-group {margin-bottom: 1.2rem;}

.content-wrap-live .ff-default .ff-el-form-control{border-radius:0!important;border-left:3px solid #013e5a;}
.content-wrap-live button[type="submit"]{width: 100%;height: 33px;color: #fff;border: none;cursor: pointer;-moz-transition-duration: .3s;-webkit-transition-duration: .3s;-o-transition-duration: .3s;-ms-transition-duration: .3s;transition-duration: .3s;border-radius:0!important;font-size:13px;}
.content-wrap-live button[type="submit"]:hover{background:#000!important;color: #fff!important;}
.css-xff{display:none;}
@media screen and (max-width: 768px) {
.content-wrap-live h3.titles{width:55px;font-size:0;height: 55px;padding:0;line-height: 55px;color: #fff;top: -55px;right: 0;position: absolute;}
.content-wrap form{padding:20px}
.css-i6dzq1{dispay:none;}
.css-xff{display:block;transition: transform 0.4s ease;position:absolute;top:30%;right:20px}
}
</style>

<section class="content-wrap-live-main">
<section class="content-wrap-live form">
<h3 class="titles">
<em>在线咨询</em>
<svg viewBox="0 0 24 24" width="18" height="18" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1">
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
<svg viewBox="0 0 24 24" width="18" height="18" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-xff"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>
</h3>

<section class="layout6s" id="formSections">
<div class="form-container">
<form action="<?php echo $_SERVER['REQUEST_URI']; $current_user = wp_get_current_user(); ?>" method="post" class="tjdiv">
<?php $module=mt_rand(100000,999999);?>
<input type='hidden' name='module' value='<?php echo $module;?>'/>
<input type='hidden' name='timestamp' value='<?php echo time();?>'/>
<input type='hidden' name='token' value='<?php echo md5($module.'#$@%!^*%*ty'.time());?>'/>
<input type='hidden' value='<?php echo home_url();?>' name='tougao_form' />
<div class="items">
<span>姓名:</span><input type="text" name="tougao_authorname" />
</div>
<div class="items">
<span>电话:</span><input type="text" name="tougao_tell" />
</div>
<div class="items">
<span>邮箱:</span><input type="text" name="tougao_authoremail" />
</div>
<div class="items">
<span>留言:</span><textarea name="tougao_content" ></textarea>
</div>
<div class="items">
<input type="submit" value="提交" id="tjbtnn"/>
</div>
</form>
</div>
</section>
</section>
</section>

<script>
document.addEventListener('DOMContentLoaded', function() {
const titleElement = document.querySelector('.titles');
const formSection = document.getElementById('formSections');
const svgElement = document.querySelector('.titles svg');
let autoExpanded = false;
let expandTimeout;

// 初始设置:10秒后自动展开
expandTimeout = setTimeout(autoExpand, 6000);

// 标题点击处理
titleElement.addEventListener('click', function() {
// 如果已经自动展开过,则清除自动展开的定时器
if (autoExpanded) {
clearTimeout(expandTimeout);
}

toggleFormSection();
});

function autoExpand() {
autoExpanded = true;
formSection.classList.add('expanded');
svgElement.classList.add('rotated');
}

function toggleFormSection() {
// 如果已经展开,则收起
if (formSection.classList.contains('expanded')) {
formSection.classList.remove('expanded');
svgElement.classList.remove('rotated');
}
// 否则展开
else {
formSection.classList.add('expanded');
svgElement.classList.add('rotated');

// 如果之前没有自动展开过,则标记为已手动展开
if (!autoExpanded) {
autoExpanded = true;
clearTimeout(expandTimeout);
}
}
}
});
</script>

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

相关教程

  • 零基础建站不用装太多软件,选对必备的几个,实用又好操作,下面给大家推荐几款新手友好的软件,跟着装就行,不用浪费时间在找软件上。第一款:建站
  • 用WordPress搭建个人博客特别简单,不用懂代码,跟着步骤一步步来,新手也能在几天内搞定,下面给大家详细说一下。第一步,准备域名和空间。域名就是
  • WordPress的下拉菜单能让网站导航更清晰,带图的二级下拉菜单更直观好看,不用写复杂代码,用插件就能实现,新手也能搞定。首先要安装一个支持带图下
  • 新手学做网站难免遇到各种问题,不用慌,很多问题都是新手必经之路,下面总结了最常见的问题和简单的解决方法,照着做就能搞定,不用到处求人。问题1
  • Hostinger 主机开启自带 CDN 步骤:Hostinger 自带 CDN 仅 Business 及以上套餐可用,入门单网站套餐无此功能。第一步:用户名密码登录Hostinger主
  • 对于企业网站、电商网站来说,产品展示功能是核心,一个好的产品展示功能能让用户快速了解产品信息,提高购买意愿。很多新手做网站的时候,不知道怎么
  • 不懂编程也能搭建个人网站,现在的工具早就实现“无代码建站”了,不用写一行代码,跟着下面的步骤来,小白也能快速拥有自己的网站,不用怕学不会。首
  • 想让网页上的文字闪烁,比如提醒用户注意某个信息,不用写复杂的JS代码,用HTML或CSS就能实现,新手也能轻松上手。第一种方法是用HTML的blink标签,
  • 零基础做网站不用花很多钱,丰俭由人,少则几百块,多则几千块,主要看你的需求,不用盲目花钱,下面给大家算一笔明白账,让你心里有数。首先是域名
  • 很多人做网站都会用现成的模板,毕竟自己从零设计网站不仅费时间,还需要专业的设计能力。但现成的模板用的人多了,很容易出现“撞脸”的情况,别人打开