从右到左更改背景div颜色指示器方向

时间:2017-07-13 08:57:05

标签: html css

我正在努力改变这个“右上角”'左上角的指示符'指示符。 right top indicating



.right {
  position: relative;
  background: aqua;
  text-align: right;
  min-width: 45%;
  padding: 10px 15px;
  border-radius: 6px;
  border: 1px solid #ccc;
  float: right;
  right: 20px;
}

.right::before {
  content: '';
  position: absolute;
  visibility: visible;
  top: -1px;
  right: -10px;
  border: 10px solid transparent;
  border-top: 10px solid #ccc;
}

.right::after {
  content: '';
  position: absolute;
  visibility: visible;
  top: 0px;
  right: -8px;
  border: 10px solid transparent;
  border-top: 10px solid aqua;
  clear: both;
}

<div class="right">
  <span>thanks</span>
</div>
&#13;
&#13;
&#13;

我试图改变'对'&#39;离开&#39;离开&#39;在css。但是没有运气。

https://stackoverflow.com/a/36715933/6677650

https://jsfiddle.net/2bekec10/

2 个答案:

答案 0 :(得分:3)

只需在选择器之前和之后从右向左更改。

.right {
  position: relative;
  background: aqua;
  text-align: right;
  min-width: 45%;
  padding: 10px 15px;
  border-radius: 6px;
  border: 1px solid #ccc;
  float: right;
  right: 20px;
}

.right::before {
  content: '';
  position: absolute;
  visibility: visible;
  top: -1px;
  left: -10px;
  border: 10px solid transparent;
  border-top: 10px solid #ccc;
}

.right::after {
  content: '';
  position: absolute;
  visibility: visible;
  top: 0px;
  left: -8px;
  border: 10px solid transparent;
  border-top: 10px solid aqua;
  clear: both;
}
<div class="right">
  <span>thanks</span>
</div>

答案 1 :(得分:1)

简单,只需用right替换left的所有实例?

.left {
  position: relative;
  background: aqua;
  text-align: left;
  min-width: 45%;
  padding: 10px 15px;
  border-radius: 6px;
  border: 1px solid #ccc;
  float: left;
  left: 20px;
}

.left::before {
  content: '';
  position: absolute;
  visibility: visible;
  top: -1px;
  left: -10px;
  border: 10px solid transparent;
  border-top: 10px solid #ccc;
}

.left::after {
  content: '';
  position: absolute;
  visibility: visible;
  top: 0px;
  left: -8px;
  border: 10px solid transparent;
  border-top: 10px solid aqua;
  clear: both;
}
<div class="left">
  <span>thanks</span>
</div>