使用CSS绘制右箭头

时间:2016-08-25 11:41:41

标签: html css

在我的项目中,我需要用右箭头绘制矩形,它应该填充带有黑色边框的白色背景。我在很多方面尝试过,但我没有得到带有白色背景和黑色边框的右箭头。

我尝试了以下代码:

HTML:
<html>
<head></head>
<body>
<div class="paddingstyleleft right-arrow1">         
<div><span><img src="images/referral_out.png"/> &nbsp;Referred To<span>
<div><strong>Dr.Sarah Willam</strong><span class="bandagealign"><span          class="bandage">3</span></span></div>            
<div class="datestyle"><img src="images/Date.png"/>&nbsp;Jul 24th,2016   &nbsp;| <div class="datestyle1 scheduledstatus"><span   class="spanwaiting">Scheduled</span></div></div></div>         
</div>
</body>
</html>


CSS:

.right-arrow1 {
 display: inline-block;
 position: relative;
 background: white;
 padding: 15px;
 height: 100px;
 padding:25px;
 border-bottom: 1px solid grey;
 width: 285px;
 border: 1px solid black;
 }
.right-arrow1:after {
content: '';
display: block;  
position: absolute;
left: 100%;
top: 50%;
margin-top: -10px;
width: 0;
height: 0;
border-top: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid black;
}

2 个答案:

答案 0 :(得分:1)

你可以检查所有箭头的小提琴:

https://jsfiddle.net/wLxag8pn/

.arrow-up {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid black;
}

.arrow-down {
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-top: 20px solid #f00;
}

.arrow-right {
  width: 0;
  height: 0;
  border-top: 60px solid transparent;
  border-bottom: 60px solid transparent;
  border-left: 60px solid green;
}

.arrow-left {
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-right: 10px solid blue;
}

答案 1 :(得分:0)

尝试使用此css获取带边框的箭头

小提琴链接https://jsfiddle.net/m4dv4f7s/

    div{
  position: relative;
  background-color: #008000;
  padding: 0px 16px;
  height: 40px;
  line-height: 40px;
  display: inline-block;
  color: white;
  border: 2px solid black;
  border-right: none;
  z-index:1;
}

div:before{
  content: '';
  position: absolute;
  left: 100%;
  z-index:-1;
  width: 28px;
  height: 28px;
  background-color: #008000;
  border-right: 2px solid black;
  border-bottom: 2px solid black;
  transform: rotate(-45deg) translate(-14px,-7px);
}