Step made with css

Asked

Viewed 81 times

1

I need to do this detail in css:

inserir a descrição da imagem aqui

The gray detail, with this step.

The question is, how do you do it with css? Or just with an image ?

  • can do with a triangle

  • How would it look ? Can you show an example of a div that has that detail on either side ? if possible in 4

2 answers

4

There are several methods of doing this, I believe that this is the simplest, using a triangle at the end of each line to simulate a step. Follow the example code with two:

.chao1{
  width:50%;
  height:20px;
  background:#cecece;
  float:left;
}
.degrau1{
  float:left;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 20px 0 0 40px;
  border-color: transparent transparent transparent #cecece;
}
.chao2{
  width:90%;
  height:20px;
  background:#cecece;
  float:left;
}
.degrau2{
  float:left;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 20px 0 0 40px;
  border-color: transparent transparent transparent #cecece;
}
<div class="chao1"></div>
<div class="degrau1"></div>
<div class="chao2"></div>
<div class="degrau2"></div>

4


div{
  font-size: 0;
  display: inline-block;
}

.ground{
  padding: 0;
  margin: 0;
  width: 40%;
  height: 20px;
  background-color: #000;
  position: relative;
  vertical-align: bottom;
}


.footer{
  width: 60%;
  height: 40px;
  background-color: #000;
  position: relative;
  vertical-align: bottom;
  padding: 0;
  margin: 0;
}

.footer::before{
    content: "";
    position: absolute;
    right: -14px;
    background-color: #F00;
    width: 26px;
    height: 20px;
    top: 8px;
    transform: rotateZ(50deg);
  }
<div class="footer"> A </div><!--
--><div class="ground"> B </div>

I left the 'step' in red. So you see the trick I did. Change the color and you’re ready.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.