【问题标题】:Html button works well, but css button doesn'tHtml 按钮效果很好,但 css 按钮不行
【发布时间】:2023-04-08 20:08:02
【问题描述】:

我不是编码专家,我创建了一个弹出脚本以在用户单击第二个弹出窗口上的 css 按钮后与 cpa 重定向一起使用。 但是当用户单击 css 按钮时,什么也没有发生。我添加了一个 html 按钮,它就像一个魅力。我试图找出根本原因,但没有运气。

run the code here on w3schools.com

$(function() {
  openUp('#overlay')
  $("#popup").on('click', function() {
    openUp('#overlay2')
    closeDown('#overlay')
  });

  function openUp(el) {
    $(el).fadeIn(500, function() {
      $(this).next().show();
    });
  }

  function closeDown(el) {
    $(el).fadeOut(500, function() {
      $(this).next().hide();
    });
  }
  $('a').each(function(index, element) {
    $(this).click(function(e) {
      e.preventDefault();
    });
  });
});
#DIV_1 {
  bottom: 0px;
  box-shadow: rgba(255, 255, 255, 0.298) 0px 0px 2px 0px inset, rgba(255, 255, 255, 0.298) 0px 1px 0px 0px inset;
  box-sizing: border-box;
  color: rgb(255, 255, 255);
  cursor: pointer;
  display: inline-block;
  height: 39px;
  left: 0px;
  letter-spacing: 2px;
  position: relative;
  right: 0px;
  text-align: center;
  text-decoration: none solid rgb(255, 255, 255);
  text-shadow: rgb(0, 79, 132) 0px 1px 0px;
  text-size-adjust: 100%;
  top: 0px;
  width: 135px;
  column-rule-color: rgb(255, 255, 255);
  perspective-origin: 53.2344px 19.5px;
  transform-origin: 53.2344px 19.5px;
  caret-color: rgb(255, 255, 255);
  background: rgb(0, 109, 183) linear-gradient(0deg, rgb(0, 109, 183), rgb(0, 139, 234)) repeat scroll 0% 0% / auto padding-box border-box;
  border-top: 1px solid rgb(0, 79, 132);
  border-right: 1px solid rgb(0, 79, 132);
  border-bottom: 2px solid rgb(0, 79, 132);
  border-left: 1px solid rgb(0, 79, 132);
  font: normal normal 700 normal 10px / 10px Lego, sans-serif;
  outline: rgb(255, 255, 255) none 0px;
  padding: 13px 14px;
}


/*#DIV_1*/

img {
  width: 100%;
  object-fit: scale-down;
  min-width: 100%;
  height: auto;
}

.form-style-5 {
  max-width: 500px;
  display: inline-block;
  padding: 8px 16px;
  background: #f4f7f8;
  margin: 8px auto;
  padding: 16px;
  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: 8px;
}

.form-style-5 label {
  display: block;
  margin-bottom: 6px;
}

.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: 30px;
}

.form-style-5 input[type="submit"],
.form-style-5 input[type="button"] {
  position: relative;
  display: block;
  padding: 17px 37px 16px 37px;
  color: #000;
  margin: 0 auto;
  font-size: 18px;
  text-align: center;
  font-style: normal;
  width: 100%;
  border: 1px solid #ffcf00;
  border-width: 1px 1px 3px;
  margin-bottom: 10px;
  background: rgb(255, 207, 0) none repeat scroll 0% 0% / auto padding-box border-box;
  box-shadow: rgba(232, 105, 2, 0.5) 0px 0px 25px 0px inset;
}

.form-style-5 input[type="submit"]:hover,
.form-style-5 input[type="button"]:hover {
  background: #ffae00;
}

.button {
  display: inline-block;
  border-radius: 4px;
  background-color: #f4511e;
  border: none;
  color: #FFFFFF;
  text-align: center;
  font-size: 28px;
  padding: 20px;
  width: 100%;
  transition: all 0.5s;
  cursor: pointer;
  margin: 5px;
}

.button span {
  cursor: pointer;
  display: inline-block;
  position: relative;
  transition: 0.5s;
}

.button span:after {
  content: '\00bb';
  position: absolute;
  opacity: 0;
  top: 0;
  right: -20px;
  transition: 0.1s;
}

.button:hover span {
  padding-right: 25px;
}

.button:hover span:after {
  opacity: 1;
  right: 0;
}
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="https://www.verifycaptcha.com/contentlockers/load.php?id={removed my aff id}"></script>
<div id="overlay" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #000; opacity: 0.05; filter: alpha(opacity=60); z-index: 99990; display: none"></div>
<div id="popup" style="position:fixed; display:none; top:110px;  width:90%; height:auto; left: 0; right: 0; margin: 0 auto; background-color:#FFFFFF; z-index:99999; padding:5px; border:solid 2px #1d8cd0; border-radius:5px;">
  <img class="aligncenter wp-image-21 size-full" src="https://images1.sykesassets.co.uk/assets/_files/cached/property/1500x1125/2906/sc_131608230613_2906_12.jpg" alt="ALT TEXT" width="492" height=a uto; />
  <p <div id="DIV_1">
    PROCEED >>
  </p>
</div>
<div id="overlay2" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #000; opacity: 0.1; filter: alpha(opacity=60); z-index: 99990; display: none"></div>
<div id="popup2" style="position:fixed; display:none; top:110px;  width:85%; height:auto; left: 0; right: 0; margin: 0 auto; background-color:#FFFFFF; z-index:99999; padding:5px; border:solid 2px #1d8cd0; border-radius:5px;">
  <p style="color:#FFFFFF;">
  </p>
  <div class="form-style-5">
    <form>
      <fieldset>
        <legend><span class="number"></span> Please enter your information</legend>
        <input type="text" name="field1" placeholder="Receiver's full name *">
        <input type="email" name="field2" placeholder="Email *">
        <textarea name="field3" placeholder="Shipping address:"></textarea>
        <label for="job">Country:</label>
        <select id="job" name="field4">
                    <option value="USA">USA</option>
                    <option value="UK">UK</option>
                </select>
        <textarea name="field5" placeholder="Greeting message: Eg. Hi Jonathan, ..Loving sister, Christina."></textarea>
      </fieldset>
      <button type="button" id="myBtn" onclick="og_load();">Apply</button>
      <button class="button" style="vertical-align:middle" onclick="og_load();"><span>Apply </span></button>
    </form>
  </div>
</div>

<head>
  <script type="text/javascript" src="https://www.verifycaptcha.com/contentlockers/load.php?(removed my affiliate code)"></script>
</head>

【问题讨论】:

  • 什么是css button
  • 您能否删除代码中不必要的部分以使其更具可读性?
  • 您确实需要修复您的 HTML(在此之前,可能是您的 HTML 基础知识)...head 在您获得 div 之后已经是无稽之谈,&lt;p &lt;div id="DIV_1"&gt; PROCEED &gt;&gt; &lt;/p&gt; 是无稽之谈。
  • 大家好抱歉给您带来不便,我已经提到我刚刚开始学习..即使这段代码对我来说也是一个成就......你们都必须从零开始......干杯伙计们..

标签: javascript jquery html css button


【解决方案1】:

不确定“css-button”是什么,但为什么不像这样将 .button 类添加到按钮:

<button class="button" type="button" id="myBtn" onclick="og_load();">Apply</button>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-14
    • 2015-12-04
    • 2014-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-09
    相关资源
    最近更新 更多