相关疑难解决方法(0)

html/css六边形与里面的图像

有没有机会将图像放在六边形内?我已经习惯了html中的六角形单元格,但是我不能用它来填充(背景?)图像.

这是我尝试过的:

.top {
  height: 0;
  width: 0;
  display: block;
  border: 20px solid red;
  border-top-color: transparent;
  border-right-color: transparent;
  border-bottom-color: red;
  border-left-color: transparent;
}
.middle {
  height: 20px;
  background: red;
  width: 40px;
  display: block;
}
.bottom {
  height: 0;
  width: 0;
  display: block;
  border: 20px solid red;
  border-top-color: red;
  border-right-color: transparent;
  border-bottom-color: transparent;
  border-left-color: transparent;
}
Run Code Online (Sandbox Code Playgroud)
<div class="hexagon pic">
  <span class="top" style="background: url(http://placekitten.com/400/400/)"></span>
  <span class="middle" style="background: url(http://placekitten.com/400/400/)"></span>
  <span class="bottom" style="background: url(http://placekitten.com/400/400/)"></span>
</div>


<div class="hexagon">
  <span class="top" style="overflow: hidden;"><img src="http://placekitten.com/400/400/" …
Run Code Online (Sandbox Code Playgroud)

html css svg css-shapes

26
推荐指数
4
解决办法
8万
查看次数

标签 统计

css ×1

css-shapes ×1

html ×1

svg ×1