CSS中的四边形梯形

时间:2016-08-12 13:57:52

标签: html css css3 shapes

嘿<我试图在CSS中重新创建这个图像。

enter image description here

到目前为止,我有这个:

https://jsfiddle.net/mstppvwe/

HTML:

<div id="container">
        <a class="page-scroll" href="#red ">
            <div class="red">
                <p>=FIRST-</p>
            </div>
        </a>
        <a class="page-scroll" href="#orange">
            <div class="orange">
                <p>--SECOND--</p>
            </div>
        </a>
        <a class="page-scroll" href="#blue">
            <div class="blue">
                <p>--- THIRDBOX ---</p>
            </div>              
        </a>

CSS:

<div id="container">
        <a class="page-scroll" href="#red ">
            <div class="red">
                <p>=FIRST-</p>
            </div>
        </a>
        <a class="page-scroll" href="#orange">
            <div class="orange">
                <p>--SECOND--</p>
            </div>
        </a>
        <a class="page-scroll" href="#blue">
            <div class="blue">
                <p>--- THIRDBOX ---</p>
            </div>              
        </a>

我玩边框并试过改造,但无济于事!

整个栏需要是一个带有文本叠加的超链接,如我的HTML模型中所示

有人可以帮忙。谢谢!

1 个答案:

答案 0 :(得分:1)

您可以在每个div上使用argCopy[0]伪元素执行此操作。

:before
#container {
  margin-left: 100px;
  width: 200px;
  right: 20px;
}
.three-bars,
.red,
.orange,
.blue {
  color: white;
  height: 50px;
  margin: 10px;
  padding: 10px;
  float: right;
  font-size: 20px;
  text-align: right;
  position: relative;
}
.red {
  width: 100px;
  background-color: #da3421;
}
.orange {
  width: 150px;
  background-color: #ec9a4c;
}
.blue {
  width: 200px;
  background-color: #5ab7c4;
}
a > div:before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 70px 70px;
  border-color: transparent transparent black;
  transform: translateX(-100%);
}
.red:before {
  border-color: transparent transparent #da3421;
}
.orange:before {
  border-color: transparent transparent #ec9a4c;
}
.blue:before {
  border-color: transparent transparent #5ab7c4;
}