【问题标题】:Does anyone know how to draw these types of arrows with CSS?有谁知道如何用 CSS 绘制这些类型的箭头?
【发布时间】:2020-03-14 08:18:46
【问题描述】:

我正在尝试制作如下所示的箭头 arrows

我正在使用 Sass 和 Bootstrap4,我想通过使用 css3 绘制它们来制作它们

我已经尝试过了,但我不知道如何实现它:

.line1 p{
	background-color: red;
	width: 80px;
	height: 80px;
	text-align: center;
	align-items: center;
	border-radius: 50%;
	color: #fff;
	font-size: 2rem;
}
.line1 p::before{
	content:'';
	display: block;
	color: blue;
	width: 300px;
	height: 10px;
	position: absolute;
	border: 5px solid red;
	margin: 30px 10px 0;
	z-index: -1;
	border-radius: 0 50px 50px 0;
  	background-color: red;
}
.line1 p::after{
	content:'';
	display: block;
	color: blue;
	width: 10px;
	height: 200px;
	position: absolute;
	border: 5px solid red;
	margin-left: 20px;
	z-index: -1;
  	background-color: red;
	
}
<div class="col-md-3  align-items-center mr-0">
    <div class="line1  my-auto">
        <p class="d-block my-auto">1</p>
    </div>
 </div>

【问题讨论】:

标签: html css sass bootstrap-4


【解决方案1】:

我来自未来,而你却做到了:

.line-container{
  
  border-bottom: 5px solid red;
  border-right: 5px dashed red;
  }
 .line-container::before{
    
    content:"";
    // display:block;
    position: absolute;
    height: 20px;
    width:20px;
    border-radius:50%;
    background: red;
    bottom:-7px;
    left:0;
}
.line-container::after{
    content:"2";
    position:absolute;
    width:55px;
    height:55px;
    border-radius:50%;
    background: red;
    bottom:-25px;
    right:-7px;
    font-size:2rem;
    font-weight:700;
    color:#fff;
    text-align:center;
}
  
.line-container p::before{
  content:"➤";
  position:absolute;
  font-size:32px;
  color:red;
  right:2.6px;
  top:-30px;
  transform: rotate(270deg);
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>


<div class="col-8 mt-5">
  <div class="line-container px-md-5 pt-5">
  <p class="mt-5"   >Lorem ipsum dolor sit amet,       consectetur adipisicing elit. Dicta minus  </p>
    
</div>
</div>

你只需要使用容器矩形的'线条',它们已经存在所以你只需要放置颜色

【讨论】:

    【解决方案2】:

    我能够找到三角形here 的初始css。基本上,您想让 div 的两个边框透明并给它们一定的宽度,这样看起来 div 会被捏成一个三角形。除了定位之外,我还添加了非常简单的球。

    您可能需要进行进一步调整以满足您的需求,但这应该可以帮助您开始 :)

    .line1 p{
    	background-color: red;
    	width: 80px;
    	height: 80px;
    	text-align: center;
    	align-items: center;
    	border-radius: 50%;
    	color: #fff;
    	font-size: 2rem;
    }
    .line1 p::before{
    	content:'';
    	display: block;
    	color: blue;
    	width: 300px;
    	height: 10px;
    	position: absolute;
    	border: 5px solid red;
    	margin: 30px 10px 0;
    	z-index: -1;
    	border-radius: 0 50px 50px 0;
      	background-color: red;
    }
    .line1 p::after{
    	content:'';
    	display: block;
    	color: blue;
    	width: 10px;
    	height: 200px;
    	position: absolute;
    	border: 5px solid red;
    	margin-left: 20px;
    	z-index: -1;
      	background-color: red;
    	
    }
    
    .arrow1{
    position: absolute;
    transform: rotate(180deg);
        left: 3px;
        top: 225px;
    width: 0;
      height: 0;
      border-right: 28px solid transparent;
        border-bottom: 60px solid red;
        border-left: 28px solid transparent;
    }
      
      .ball1{
      position: absolute;
      left: 300px;
      top: 15px;
      background-color: red;
      border-radius: 50%;
      height: 50px;
      width: 50px;
      }
    <div class="col-md-3  align-items-center mr-0" style="position: relative;">
        <div class="line1  my-auto">
            <p class="d-block my-auto">1</p>
            <div class='arrow1'></div>
            <div class='ball1'></div>
        </div>
     </div>

    【讨论】:

      【解决方案3】:

      好吧,我会给你一个快速的 PoC,你可以很容易地扩展它,以便可以使用预制模板为实例定义它的使用,但如果你想要所有其他方向和东西,你将不得不做额外的创意工作并自己填写空白,但这可能有助于您入门。干杯!

      .magic-arrows {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        height: var(--arrow-circle-height);
        width: var(--arrow-circle-width);
        background-color: var(--arrow-color);
        border-radius: 50%;
        overflow: visible;
      }
      .magic-arrows:before, .magic-arrows:after {
        content: '';
        display: block;
        position: absolute;
        color: var(--arrow-color);
        border: var(--arrow-color) var(--arrow-dash-size) dashed;
        overflow: visible;
        z-index: -1;
      }
      .magic-arrows:before {
        height: 0;
        width: calc( var(--arrow-circle-width) + var(--arrow-width) );
        left: var(--arrow-circle-width);
        top: 50%;
        transform: translateY(-50%);
      }
      .magic-arrows:after {
        width: 0;
        height: calc( var(--arrow-circle-width) + var(--arrow-width) );
        top: var(--arrow-circle-width);
        left: 50%;
        transform: translateX(-50%);
      }
      .magic-arrows .arrow-right, .magic-arrows .dot-down {
        position: absolute;
        font-size: var(--arrow-size);
        color: var(--arrow-color);
      }
      .magic-arrows .arrow-right {
        top: 50%;
        left: calc(var(--arrow-circle-width) + var(--arrow-width) + var(--arrow-size) + 1rem);
        transform: translateY(-55%);
      }
      .magic-arrows .dot-down {
        position: absolute;
        left: 50%;
        top: calc(var(--arrow-circle-width) + var(--arrow-width) + var(--arrow-size) + 1rem);
        transform: translateX(-55%) rotate(90deg);
      }
      <div class="magic-arrows" 
           style="--arrow-color: red;
                  --arrow-circle-height: 3rem;
                  --arrow-circle-width: 3rem;
                  --arrow-width: 10rem;
                  --arrow-dash-size: 5px;
                  --arrow-size: 2rem;">
        <span>3</span>
        
        <div class="arrow-right">➤</div>
        <div class="dot-down">◉</div>
      </div>

      【讨论】:

        猜你喜欢
        • 2020-10-04
        • 1970-01-01
        • 2018-04-12
        • 1970-01-01
        • 1970-01-01
        • 2016-03-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多