输入标记运行意外的CSS效果

如何解决输入标记运行意外的CSS效果

我正在尝试设置Drupal主题按钮的样式,但是当我将相同的CSS放入“ input”标签中时出了点问题。

在此代码段示例中,我们可以使用相同的CSS代码验证2种不同的效果

我认为这是一个Drupal问题,但不是。当我将代码移到外面并尝试使用input标签时,它的显示方式与Drupal网站中的显示方式相同。

/* Buttons */
.form-submit {
  cursor: pointer;
  margin-left: 5px;
  margin-bottom: 15px;
  text-shadow: 0 -2px 0 #4a8a65,0 1px 1px #c2dece;
  Box-sizing: border-Box;
  font-size: 2em;
  font-family: Helvetica,Arial,Sans-Serif;
  text-decoration: none;
  font-weight: bold;
  color: #5ea97d;
  height: 65px;
  line-height: 65px;
  padding: 0 32.5px;
  display: inline-block;
  width: auto;
  background: -webkit-gradient(linear,left top,left bottom,from(#9ceabd),color-stop(26%,#9ddab6),to(#7fbb98));
  background: linear-gradient(to bottom,#9ceabd 0%,#9ddab6 26%,#7fbb98 100%);
  border-radius: 5px;
  border-top: 1px solid #c8e2d3;
  border-bottom: 1px solid #c2dece;
  top: 0;
  -webkit-transition: all 0.06s ease-out;
  transition: all 0.06s ease-out;
  position: relative;
}
.form-submit:visited {
  color: #5ea97d;
}

.form-submit:hover {
  background: -webkit-gradient(linear,from(#baf1d1),#b7e4ca),to(#96c7ab));
  background: linear-gradient(to bottom,#baf1d1 0%,#b7e4ca 26%,#96c7ab 100%);
}

.form-submit:active {
  top: 6px;
  text-shadow: 0 -2px 0 #7fbb98,0 1px 1px #c2dece,0 0 4px white;
  color: white;
}
.form-submit:active:before {
  top: 0;
  Box-shadow: 0 3px 3px rgba(0,0.7),0 3px 9px rgba(0,0.2);
}

.form-submit:before {
  display: inline-block;
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  z-index: -1;
  top: 6px;
  border-radius: 5px;
  height: 65px;
  background: linear-gradient(to top,#1e5033 0%,#378357 6px);
  -webkit-transition: all 0.078s ease-out;
  transition: all 0.078s ease-out;
  Box-shadow: 0 1px 0 2px rgba(0,0.3),0 5px 2.4px rgba(0,0.5),0 10.8px 9px rgba(0,0.2);
}
<input type="submit" id="edit-submit" name="op" value="Comprar" class="form-submit">
<a class="form-submit" href="#0">Comprar</a>

解决方法

伪元素::before::after不适用于某些元素,例如输入。渲染的不同之处就在于此。问题已经提出,我邀请您阅读此答案以获取更多详细信息。:https://stackoverflow.com/a/4660434

,

嗯,嗯...我不是CSS专家,实际上我是个自学成才的人,但是我可以通过下面的代码片段来改善问题的解决方案。 如果我们无法以特定的方式做某事,我们必须跳出思维框框,找到一种无论如何都能使之正常工作的方法。如果不相等,但应该是相似的。 有人可以帮助我做得更好吗?

/* Buttons */
.form-submit {
  /* :before */

  top: 6px;
  border-radius: 5px;
  height: 65px;
  background: linear-gradient(to top,#1e5033 0%,#378357 6px);
  /* -webkit-transition: all 0.078s ease-out; 
  transition: all 0.078s ease-out; */ 
  box-shadow: 0 1px 0 2px #9ddab6,0 5px 2.4px #7fbb98,0 8px 9px rgba(0,0.2);
  
  cursor: pointer;
  margin-left: 5px;
  margin-bottom: 15px;
  text-shadow: 0 -2px 0 #4a8a65,0 1px 1px #c2dece;
  box-sizing: border-box;
  font-size: 2em;
  font-family: Helvetica,Arial,Sans-Serif;
  text-decoration: none;
  font-weight: bold;
  color: #5ea97d;
  height: 65px;
  line-height: 65px;
  padding: 0 32.5px;
  display: inline-block;
  width: auto;
  background: -webkit-gradient(linear,left top,left bottom,from(#9ceabd),color-stop(26%,#9ddab6),to(#7fbb98));
  background: linear-gradient(to bottom,#9ceabd 0%,#9ddab6 26%,#7fbb98 100%);
  /* border-radius: 5px; */
  border-top: 1px solid #c8e2d3;
  border-bottom: 1px solid #c2dece;
  top: 0;
  -webkit-transition: all 0.06s ease-out;
  transition: all 0.06s ease-out;
  position: relative;
}


.form-submit:visited {
  color: #5ea97d;
}

.form-submit:hover {
  background: -webkit-gradient(linear,from(#baf1d1),#b7e4ca),to(#96c7ab));
  background: linear-gradient(to bottom,#baf1d1 0%,#b7e4ca 26%,#96c7ab 100%);
}

.form-submit:active {
  top: 6px;
  text-shadow: 0 -2px 0 #7fbb98,0 1px 1px #c2dece,0 0 4px white;
  color: white;
  box-shadow: 0 0px 0 2px rgba(0,0.3),0 0px 2.4px rgba(0,0.5),0 0px 9px rgba(0,0.2);
}
<input type="submit" id="edit-submit" name="op" value="Comprar" class="form-submit">
<a class="form-submit" href="#0">Comprar</a>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?