首页 > 解决方案 > 使用 :after 选择性进行内联样式设置

问题描述

我有下面这样的样式表,

h3 {
  position: relative;
  background: #dfefff;
  box-shadow: 0px 0px 0px 5px #dfefff;
  border: dashed 2px white;
  padding: 0.2em 0.5em;
  color: #454545;
}

h3:after {
  position: absolute;
  content: '';
  left: -7px;
  top: -7px;
  border-width: 0 0 15px 15px;
  border-style: solid;
  border-color: #fff #fff #a8d4ff;
  box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.15);
}
<h3>Title</h3>

但是在我的网络规则中,我不能使用标签

所以我必须使用 like

<h3 style ="position: relative;background: #dfefff;~~">

我怎样才能使用h3:after这种风格?

标签: htmlcsspseudo-class

解决方案


您不能添加pseudooperator inline Style,因为Pseudooperator 只能在 CSS 中使用classes,并且Ids

并且您正在考虑添加pseudo具有style属性的运算符,这是不可能的,
有关更多信息,请访问本文。这将对您有所帮助 https://www.w3.org/TR/css-style-attr/


推荐阅读