1

I want to draw this shape using HTML and CSS:

enter image description here

My problem is how to draw the 2 lines in left and in the right of green rectangle.

This is my attempt:

.c{
 width: 225px;
 float: left;
 padding: 13px;
 margin: 5px;
 border-width:2px;
 border-color:#777;
 border-style:solid;
 text-align: center; 
 border-radius: 30px;
}

.c .cadre{
  background: #60b000;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  margin: 10px auto 0px;
      
}

.c .cadre .num{
  font-size: 17px;
  margin-right: 2px;
  color: white;
}
<h3> Commment ça marche</h3>
            <div class="c"> 
                <h3> titre1 </h3>
                The element selector selects elements based on the element name.
                <div class="cadre"><span class="num">1</span></div>
            </div>

Thank you for help in advance.

4
  • 2
    There seems to be only one line below the green bar. Could you maybe post a slightly larger picture for better visualization? Commented Feb 18, 2015 at 16:22
  • 4
    Essentially the same question as - stackoverflow.com/questions/23584120/… Commented Feb 18, 2015 at 16:23
  • That image is better. It looks like you would have to use the approach posted by Daniel along with a bit of box-shadow for the lighter colored line at the bottom (or even border). Commented Feb 18, 2015 at 16:29
  • @harry maybe they are not 2 lines, but the most important for me is to achieve this shape. I said that it's my attempt. t Thought that the best is to draw 2 lines but surely professionnal who deal with CSS have an other idea. Commented Feb 18, 2015 at 16:32

1 Answer 1

3

Use a pseudo-element like :before, also move the styles from cadre to style the span num.

Try this:

.c {
  width: 225px;
  float: left;
  padding: 13px;
  margin: 5px;
  border-width: 2px;
  border-color: #777;
  border-style: solid;
  text-align: center;
  border-radius: 30px;
}
.c .cadre {
  position:relative;
}
.c .cadre .num {
  background: #60b000;
  border-radius: 3px;
  margin: 10px auto 0px;
  width: 20px;
  height: 20px;
  display:block;
  font-size: 17px;
  color: white;
  position:relative;
  z-index:10;
}
.c .cadre:before {
  content:" ";
  width:80%;
  position:absolute;
  height:5px;
  left:50%;
  top:50%;
  transform:translate(-50%, -50%);
  background:orange;
}
<h3> Commment ça marche</h3>
<div class="c">
  <h3> titre1 </h3>
  The element selector selects elements based on the element name.
  <div class="cadre"><span class="num">1</span>
  </div>
</div>

Sign up to request clarification or add additional context in comments.

1 Comment

@SADOK glad to help U mate

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.