增加三角形的大小

时间:2018-07-01 10:57:51

标签: html css

我有这个标注云,请看一下代码。

div.callout {
  background-color: #444;
  background-image: -moz-linear-gradient(top, #444, #444);
  position: relative;
  color: #ccc;
  padding: 10px;
  border-radius: 3px;
  box-shadow: 0px 0px 20px #999;
  margin: 25px;
  min-height: 100px;
  border: 1px solid #333;
  text-shadow: 0 0 1px #000;
  width: 700px;
  margin-top: -58px;
  margin-left: 393px;
  border-radius: 15px;
  /*box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;*/
}

.callout::before {
  content: "";
  width: 0px;
  height: 0px;
  border: 0.8em solid transparent;
  position: absolute;
}

.callout.right::before {
  left: -20px;
  top: 40%;
  width: -10px;
  margin-right: 10px;
  border-right: 5px solid blue;
}
<div class="callout right"> </div>

我想在一开始就增加三角形output(蓝色的三角形)的大小,但我无法这样做。请看一下并在这里帮助我。

2 个答案:

答案 0 :(得分:3)

您可以增加边框宽度并调整位置:

.callout.right::before {
  left: -25px;                   /* adjust the location of triangle */
  top: 40%;
  margin-right: 10px;
  border-right: 10px solid blue; /* increase the border width */
}

这是代码段:

div.callout {
  background-color: #444;
  background-image: -moz-linear-gradient(top, #444, #444);
  position: relative;
  color: #ccc;
  padding: 10px;
  border-radius: 3px;
  box-shadow: 0px 0px 20px #999;
  margin: 25px;
  min-height: 100px;
  border: 1px solid #333;
  text-shadow: 0 0 1px #000;
  width: 700px;
  margin-top: -58px;
  margin-left: 393px;
  border-radius: 15px;
  /*box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;*/
}

.callout::before {
  content: "";
  width: 0px;
  height: 0px;
  border: 0.8em solid transparent;
  position: absolute;
}

.callout.right::before {
  left: -25px;
  top: 40%;
  margin-right: 10px;
  border-right: 10px solid blue;
}
<div class="callout right"> </div>

答案 1 :(得分:2)

您可以像这样调整代码,并且只需更改边框的宽度即可轻松更改三角形的尺寸:

div.callout {
  background-color: #444;
  background-image:linear-gradient(top, #444, #444);
  position: relative;
  color: #ccc;
  padding: 10px;
  border-radius: 3px;
  box-shadow: 0px 0px 20px #999;
  margin: 25px;
  min-height: 100px;
  border: 1px solid #333;
  width: 200px;
  border-radius: 15px;
}

.callout::before {
  content: "";
  width: 0px;
  height: 0px;
  border: 0.8em solid transparent;
  position: absolute;
}

.callout.right::before {
  right:100%;
  top: 50%;
  transform:translateY(-50%);
  border-right: 15px solid blue; /*Change only this value to control the size*/
}
<div class="callout right"> </div>