создание стрелки с помощью before after

#html #css

#HTML #css

Вопрос:

Добрый день, у меня есть ссылка, которая должна содержать текст стрелка, выглядящая следующим образом:

введите описание изображения здесь

Я сделал стрелку, но не знаю, как сделать этот белый фон, дело в том, что я должен использовать псевдоэлементы

 .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>	  

Комментарии:

1. просто интересно, вместо использования таких хаков, почему бы вам просто не использовать изображение стрелки?

Ответ №1:

Вот как вы создаете из псевдоэлемента. Просто измените цвет.

 .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>	  

Надеюсь, это поможет. Приветствия!

Ответ №2:

попробуйте это:

 .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>