html - 如何在 html/css 中以直线对齐形状之间的箭头?

标签 html css

我有一个屏幕截图,如下所示,我试图在 html/css 中复制它:

enter image description here

此刻,我可以得到 fiddle 中的所有内容绿色和橙色箭头未正确对齐。

为了使箭头和桌面对齐成一条直线,我使用的 CSS 代码是:

.tvs
{
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem;    
}



问题陈述:

我想知道我应该对 fiddle 进行哪些更改,以便我能够在桌面之间的直线上对齐绿色和橙色箭头。

最佳答案

您可以将它们包裹在一个 div 元素中,然后在该 div 上使用 text-align: center

.tvs {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
}

.arrows-element {
  text-align: center;
}
<div class="tvs">

  <div class="arrows">
    <img src="https://thebettersoftwarecompany.com/wp-content/uploads/2018/05/End-Arrows-left.png" alt="" width="49" height="62" class="aligncenter size-full wp-image-8105" />
  </div>
  <div class="tv">
    <img src="https://thebettersoftwarecompany.com/wp-content/uploads/2018/05/Tv-Screen-2.png" alt="" width="177" height="129" class="aligncenter size-full wp-image-8081" />
  </div>

  <div class="arrows-element">
    <div class="green-arrow">
      <img src="https://thebettersoftwarecompany.com/wp-content/uploads/2018/05/green-arrow.png" alt="" width="49" height="24" class="aligncenter size-full wp-image-8109">
    </div>

    <div class="orange-arrow">
      <img src="https://thebettersoftwarecompany.com/wp-content/uploads/2018/05/orange-arrow-v1.png" alt="" width="126" height="24" class="aligncenter size-full wp-image-8114" />
    </div>
  </div>


  <div class="tv">
    <img src="https://thebettersoftwarecompany.com/wp-content/uploads/2018/05/Tv-Screen-2.png" alt="" width="177" height="129" class="aligncenter size-full wp-image-8081" />
  </div>

  <div class="arrows-element">
    <div class="green-arrow">
      <img src="https://thebettersoftwarecompany.com/wp-content/uploads/2018/05/green-arrow.png" alt="" width="49" height="24" class="aligncenter size-full wp-image-8109">
    </div>

    <div class="orange-arrow">
      <img src="https://thebettersoftwarecompany.com/wp-content/uploads/2018/05/orange-arrow-v1.png" alt="" width="126" height="24" class="aligncenter size-full wp-image-8114" />
    </div>
  </div>


  <div class="tv">
    <img src="https://thebettersoftwarecompany.com/wp-content/uploads/2018/05/Tv-Screen-2.png" alt="" width="177" height="129" class="aligncenter size-full wp-image-8081" />
  </div>

  <div class="arrows-element">
    <div class="green-arrow">
      <img src="https://thebettersoftwarecompany.com/wp-content/uploads/2018/05/green-arrow.png" alt="" width="49" height="24" class="aligncenter size-full wp-image-8109">
    </div>

    <div class="orange-arrow">
      <img src="https://thebettersoftwarecompany.com/wp-content/uploads/2018/05/orange-arrow-v1.png" alt="" width="126" height="24" class="aligncenter size-full wp-image-8114" />
    </div>
  </div>


  <div class="tv">
    <img src="https://thebettersoftwarecompany.com/wp-content/uploads/2018/05/Tv-Screen-2.png" alt="" width="177" height="129" class="aligncenter size-full wp-image-8081" />
  </div>

  <div class="arrows">
    <img src="https://thebettersoftwarecompany.com/wp-content/uploads/2018/05/End-Arrows-right.png" alt="" width="49" height="62" class="aligncenter size-full wp-image-8105" />
  </div>

</div>

关于html - 如何在 html/css 中以直线对齐形状之间的箭头?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50554475/

相关文章:

html - 防止 float div 换行

html - 链接里面的图片

javascript - ExpressJS 用于在 GET 请求上呈现内容

php - 用替代颜色为表格着色

javascript - CSS Flex Center 和 Masonry JS 冲突

javascript - 使用 CSS + jQuery 在悬停时制作翻转效果,在模糊时淡入淡出

javascript - 当部分高于屏幕高度时如何暂时禁用 "scrollify"

html - 带有 display flex 的图像定位/div 高度

javascript - 使用 JavaScript 动态控制 HTML5 音频

css - 如何找出特定页面上应用了哪些 CSS 规则?