Peter Peter - 6 months ago 14
HTML Question

Multible css Triangle effect with float left

How can i create the same "triangle"

border
s like on the picture with pure css?

SS

Fiddle:

CODE



/* .TEST {
border-bottom: 169px solid red;
border-top: 169px solid red;
border-left: 42px solid transparent;
border-right: 42px solid transparent;
height: 169px;
width: 169px;
} */

#d {
width: 100%;
font-size: 25px;
}
#d1,
#d2,
#d3 {
width: 33%;
float: left;
padding: 30px;
color: #D2B746;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
}
#d2 {
width: 34%;
color: #000;
}
.gradient_black {
background: #303437;
}
.gradient_gold {
background: #d4ba49;
}

<div id="d">
<div id="d1" class="gradient_black">Test</div>
<div id="d2" class="gradient_gold TEST">Test</div>
<div id="d3" class="gradient_black">Test</div>
</div>





EDIT:
Or should i use SVGs?

Answer

using transform: skew() you can achieve this

Note: I made a few tweaks to your code

*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0
}
#d {
  width: 100%;
  font-size: 25px;
  background: #303437;
  display: flex
}
#d1,
#d2,
#d3 {
  width: calc((100% / 3) - 6px);
  padding: 30px;
  color: #D2B746;
}
#d2.gradient_gold {
  background: #d4ba49;
  color: #000;
}
#d>div {
  transform: skew(-20deg)
}
<div id="d">
  <div id="d1" class="gradient_black">Test</div>
  <div id="d2" class="gradient_gold">Test</div>
  <div id="d3" class="gradient_black">Test</div>
</div>