【问题标题】:Shaping the Navbar's Bottom Border塑造导航栏的底部边框
【发布时间】:2016-11-10 16:40:17
【问题描述】:

我正在尝试塑造导航包装的底部边框,以便在其中心弹出一个三角形(例如下图)。

有没有一种方法可以通过编辑/转换导航包装器关于底部边框的 CSS 来创建这个形状?

三角形具有与导航包装器相同的不间断背景图案和底部边框阴影,所以我认为这应该通过 CSS 转换来完成,而不是在边框上添加 CSS/图像形状。

IE:

谢谢!

【问题讨论】:

标签: css border transform css-transforms


【解决方案1】:

您可以为此使用 CSS 伪元素 :before:after。请看下面的sn-p:

.nav-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
  background: #33b5e5;
  color: #fff;
  font-size: 50px;
  font-weight: 700;
  border-bottom: 6px solid #8ACEE9;
  position: relative;
}

.nav-bar:after {
  content: '';
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 30px solid transparent;
  border-right: 30px solid transparent;
  border-top: 30px solid #33b5e5;
}

.nav-bar:before {
  content: '';
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 40px solid transparent;
  border-right: 40px solid transparent;
  border-top: 40px solid #8ACEE9;
}
<div class="nav-bar">
  Navbar
</div>

希望这会有所帮助!

【讨论】:

  • 太棒了!差不多就行了,谢谢——你知道如何在边框上添加背景图像,这样图像就会被三角形遮住吗?
猜你喜欢
  • 2013-10-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-24
  • 2018-12-22
  • 2020-07-18
相关资源
最近更新 更多