首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >输入标记运行意外的CSS效果

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

Stack Overflow用户
提问于 2020-09-18 05:26:23
回答 2查看 32关注 0票数 0

我正在尝试设计我的Drupal主题按钮的样式,但是当我把同样的CSS放到"input“标签中时出现了一些错误。

在这个代码片段示例中,我们可以用相同的CSS代码验证两种不同的效果。

我以为这是Drupal的问题,但事实并非如此。当我将代码放到外部并使用input标记进行尝试时,它显示了与Drupal站点中相同的方式。

代码语言:javascript
复制
/* 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, left top, left bottom, from(#baf1d1), color-stop(26%, #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, 0, 0.7), 0 3px 9px rgba(0, 0, 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, 0, 0.3), 0 5px 2.4px rgba(0, 0, 0, 0.5), 0 10.8px 9px rgba(0, 0, 0, 0.2);
}
代码语言:javascript
复制
<input type="submit" id="edit-submit" name="op" value="Comprar" class="form-submit">
<a class="form-submit" href="#0">Comprar</a>

EN

回答 2

Stack Overflow用户

发布于 2020-09-18 07:14:24

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

票数 0
EN

Stack Overflow用户

发布于 2020-09-18 23:27:35

好吧,好吧..。我不是CSS专家,实际上我是一些自学成才的人,但我可以像下面的片段一样改进这个问题的解决方案。如果我们不能以特定的方式做某件事,我们就必须跳出框框,找到一种方法让它工作。如果不相等,但与预期的相似。有没有人能帮我把它做得更好?

代码语言:javascript
复制
/* 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, 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, left top, left bottom, from(#baf1d1), color-stop(26%, #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, 0, 0.3), 0 0px 2.4px rgba(0, 0, 0, 0.5), 0 0px 9px rgba(0, 0, 0, 0.2);
}
代码语言:javascript
复制
<input type="submit" id="edit-submit" name="op" value="Comprar" class="form-submit">
<a class="form-submit" href="#0">Comprar</a>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63946405

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档