Search code examples
htmlcsscss-shapes

Creating box having css arrow using css3


.box {
  position: relative;
  margin: 18px;
  width: 8em;
  height: 6em;
  border: 1px solid rgb(77, 77, 77);
  color: #FF1919;
  background-color: pink;
}
.box:hover {
  width: 8em;
  margin: 18px;
}
.box:before {
  content: '';
  position: relative;
  width: 30%;
  left: 18px;
  right: 80%;
  height: 40px;
  top: 30%;
  background: rgba(0, 0, 0, 0.1);
  display: inline-block;
  background-color: blue;
}
.box:after {
  content: '';
  position: absolute;
  left: 43%;
  top: 30%;
  margin-top: -18px;
  border-style: solid;
  border-width: 40px;
  border-color: transparent transparent transparent rgba(0, 0, 0, 0.1);
}
<div class="box"></div>

I have created one arrow and in that I want to highlight the arrow head with blue colour which is grey.

I also want to use this total arrow as a button to navigate to next scene page with html extension.

For that I am using:

<div style="position: absolute; right: 40px; bottom: 70px;">
    <form action="abc.html" align="right" style="margin-right:100px ;   display:inline">
        <input type="submit" class="box"></input>
    </form>
</div>

but it is taking a single part of that css object(rectangle) box and leaving other portions.


Solution

  • For navigation you can add <a> tag in your html page and for color of the class .box:after change the border color as below:

    HTML:

    <a href="http://www.w3schools.com" target="_blank"><div class="box"></div></a>
    

    CSS:

     .box:after {
          content: '';
          position: absolute;
          left: 43%;
          top: 30%;
          margin-top: -18px;
          border-style: solid;
          border-width: 40px;
          border-color: transparent transparent transparent **rgba(7, 17, 241, 1);**    }
    

    FIDDLE