用前+后做箭头

时间:2016-10-10 08:41:56

标签: html css

美好的一天 我有一个链接,必须有文字+箭头,如下所示:

enter image description here

我已经完成了箭头,但不知道如何制作那个白色背景 问题是我必须使用伪元素

.hiretext{
	margin-top:185px;
	padding:5px 2px 5px 5px;
	position:absolute;
	background-color: #1a1e27;
	color:white;
	font-family:FrutigerCELight,Arial,Helvetica,sans-serif;
	font-size:20px;
	text-transform: uppercase;
	font-weight: 900;
}
.hirelink{
	display:inline-block;		
  	width:	0; 		
  	height:	0; 
	border-top:	solid transparent;
	border-bottom: solid transparent;
	border-left: solid black;	
	border-width:7px;
	content:' ';
	}
<div class="hiretext">
		<a href="#" class="hirelink">
			hire us
		</a>
</div>	

2 个答案:

答案 0 :(得分:0)

以下是您从伪元素创建的方式。只需改变颜色。

.hiretext {
  margin-top:105px;
  padding:5px 2px 5px 5px;
  position:absolute;
  color:white;
  font-family:FrutigerCELight,Arial,Helvetica,sans-serif;
  font-size:20px;
  text-transform: uppercase;
  font-weight: 900;
}

.hirelink {
  position: relative;
}

.hirelink:after {
  content: '';
  border-left: 10px solid black;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  width: 0;
  height: 0;
  position: absolute;
  top: 10px;
  right: -42px;
}

.hirelink:before {
  content: '';
  height: 30px;
  width: 30px;
  background: red;
  border-radius: 50%;
  position: absolute;
  top: 0;
  right: -50px;
}
<div class="hiretext">
  <a href="#" class="hirelink"> hire us</a>
</div>	

希望它有所帮助。干杯!

答案 1 :(得分:0)

试试这个:

.hiretext {
  padding: 5px 2px 5px 5px;
  position: absolute;
  background-color: #1a1e27;
  font-family: FrutigerCELight, Arial, Helvetica, sans-serif;
  font-size: 20px;
  text-transform: uppercase;
  font-weight: 900;
  width: 200px;
}
.hirelink {
  position: relative display: inline-block;
  color: white;
}
.hirelink:after {
  content: "►";
  position: absolute;
  right: 5px;
  margin: auto;
  background: white;
  color: #1a1e27;
  border-radius: 15px;
  width: 28px;
  text-align: center;
  height: 28px;
  font-size: 20px;
}
<div class="hiretext">
  <a href="#" class="hirelink">
			hire us
		</a>
</div>