CSS:包含内容的箭头框

时间:2017-03-09 11:34:49

标签: html css

我用右上箭头制作Div,并在其中有内容。

就像在enter image description here

中一样



.arrow_box {
  	position: relative;
  	background: #FFF;
  	border: 2px solid #fff;
    box-shadow: 0px 0px 5px #000;
  }
  .arrow_box:after, .arrow_box:before {
  	bottom: 100%;
  	left: 99%;
  	border: solid transparent;
  	content: " ";
  	height: 0;
  	width: 0;
  	position: absolute;
  	pointer-events: none;
  }

  .arrow_box:after {
  	border-color: rgba(136, 183, 213, 0);
  	border-bottom-color: #FFF;
  	border-width: 15px;
  	margin-left: -15px;
  }
  .arrow_box:before {
  	border-color: rgba(0, 0, 0, 0);
  	border-bottom-color: #FFF;
  	border-width: 21px;
  	margin-left: -21px;
  }

<div class="arrow_box">DO You Really Want this Feature?</div>
&#13;
&#13;
&#13;

不知怎的,我无法获得我的输出。

任何帮助都会很棒?

谢谢

1 个答案:

答案 0 :(得分:0)

body {
  padding: 3em;
  font-family: sans-serif;
}

.arrow_box {
  position: relative;
  background-color: #fff;
  box-shadow: 0px 0px 10px rgba(0, 0, 0, .5);
  padding: 1em 2em;
  color: #aaa;
}

.arrow_box::after,
.arrow_box::before {
  content: "";
  background-color: #fff;
  position: absolute;
  top: 0;
  left: 100%;
  height: 1em;
  width: 1em;
  box-shadow: 0 0 10px rgba(0, 0, 0, .5);
  transform-origin: center center;
  transform: translate(-2em, -.5em) rotate(45deg);
  z-index: -1;
}

.arrow_box::before {
  z-index: 1;
  box-shadow: none;
}
<div class="arrow_box">DO You Really Want this Feature?</div>