如何使用CSS创建带顶尖的div [英] How can I create div with a pointed top with CSS

查看:91
本文介绍了如何使用CSS创建带顶尖的div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到很多线程远程相关,基本上建议CSS三角形在:: before或:: before伪元,但没有一个真正的淘汰。我抛出这个,看看有没有任何想法。

I've see a lot of threads remotely related that basically suggest CSS triangles in the ::after or ::before pseudos, but none have really panned out. I'm throwing this out to see if anyone has any ideas.

我想要创建一个具有尖角或倾斜顶部的div,它仍然与div的其余部分保持一致的边框和box-shadow。

I'm looking to create a div with a pointed or pitched top that still maintains a uniform border and box-shadow with the rest of the div.

查看我要创建的图片的链接:

See link for an image of what I'm trying to create:

推荐答案

应该让您开始:

这是一个更新的小提琴,更好的呈现。

.first {
  display: inline-block;
  width: 3em;
  height: 3em
}
.second {
  position: relative;
  display: inline-block;
  width: 3em;
  height: 3em
}
.third {
  position: absolute;
  display: inline-block;
  width: 0;
  height: 0;
  line-height: 0;
  border: 1.5em solid transparent;
  margin-top: -1em;
  border-bottom: 1em solid #007BFF;
  left: 0em;
  top: 0em
}
.forth {
  position: absolute;
  display: inline-block;
  width: 0;
  height: 0;
  line-height: 0;
  border: 1.5em solid #007BFF;
  border-bottom: 1.5em solid #007BFF;
  left: 0em;
  top: 1.5em
}

<span class="first"><span class="second"><i class="third"></i><i class="forth"></i></span></span>

这篇关于如何使用CSS创建带顶尖的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆