Currently, I am utilizing the CSS3 rotate
value to create an arrowhead effect for modal boxes. However, I now require a full arrowhead design with a bottom border. As this involves rotating a div at a 45° angle, adding another border
to either side will not provide the desired solution.
Initially, my plan was to style the :after
pseudo selector of the div and vertically center it. Unfortunately, it seems to be inheriting the rotation value. Despite attempting to set the value to none
and manually adjust the rotation angle, I have been unable to achieve the desired straight horizontal border reset. Any suggestions on how to accomplish this?
Following Harry's recommendation, I adjusted the angle of the :after
selector to -45deg
and set the top
value to 50%
. The only remaining issue is that it does not fully extend to the left and right sides of the div. Are there any solutions for this problem?
.arrow {
background-color: transparent;
border-top: 2px solid #c7c7c7;
border-left: 2px solid #c7c7c7;
position: relative;
height: 18px;
width: 18px;
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.arrow:after {
content: "";
background: #c7c7c7;
display: inline-block;
position: absolute;
top: 50%;
height: 2px;
width: 100%;
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
<div class="arrow"></div>