4

I'm trying to make a menu with a curvy triangle pointers. I tried but not able to achieve the curvy one.

<div>

</div>

div{
    position:relative;
    left:20%;
    height:250px;
    width:150px;
    border:1px solid #000;
    top:10%;
    background:#fff;
}
div:before, div:after{
    position:absolute;
    content:'';
    left:-20px;
    border:10px solid transparent;
    border-right-color:#fff;
    top:30px;
 }
div:after{
    left:-21px;
    border-right-color:#000;
    z-index:-1
}

Refer the fiddle

Also i have attached image above for what i'm actually looking forenter image description here

I recommend solutions without using SVG

7
  • 2
    I think you might be asking too much of css here. Have you tried using an image instead? Commented Jun 14, 2016 at 10:34
  • I can make easily with image @Graham. But any possibilities with css Commented Jun 14, 2016 at 10:37
  • It is possible to do with transform. Commented Jun 14, 2016 at 10:42
  • 1
    you can try with this one jsfiddle.net/ffneu0cz/3 Commented Jun 14, 2016 at 10:44
  • @Harry check my image. I want curvy al the way. Not only at the top of the triangle Commented Jun 14, 2016 at 10:59

2 Answers 2

3

Please check this fiddle.

And another fiddle

I have used box with transform and box-shadow on before and after. Please check my code and if you are getting confusion on any point then let me know. Thank you

CSS

div{
  position:relative;
  left:20%;
  height:250px;
  width:150px;
  border:1px solid #000;
  top:10%;
  background:#fff;
}
div:before, div:after{
  position:absolute;
  content:'';
  width:30px;
  height:30px;
  left:-12px;
  background:#fff;
  top:30px;
-ms-transform: rotate(45deg); /* IE 9 */
    -webkit-transform: rotate(45deg); /* Chrome, Safari, Opera */
    transform: rotate(45deg);

    border-radius:5px;
}
div:after{
  left:-13px;
  border-right-color:#000;
  z-index:-1;
  border:1px solid #000;
  top:29px;
  box-shadow: 0px 1px 6px 0px #282828;
}
Sign up to request clarification or add additional context in comments.

Comments

3

This might help

/**
 * How to make 3-corner-rounded triangle in CSS (SO)
 * https://stackoverflow.com/q/14446677/1397351
 */
.triangle {
	position: relative;
	background-color: orange;
	text-align: left;
}
.triangle:before,
.triangle:after {
	content: '';
	position: absolute;
	background-color: inherit;
}
.triangle,
.triangle:before,
.triangle:after {
	width:  100px;
	height: 100px;
	border-top-right-radius: 30%;
}

.triangle {
	transform: rotate(90deg) skewX(-30deg) scale(1,.866);
}
.triangle:before {
	transform: rotate(-135deg) skewX(-45deg) scale(1.414,.707) translate(0,-50%);
}
.triangle:after {
	transform: rotate(135deg) skewY(-45deg) scale(.707,1.414) translate(50%);
}



/* styles below for demonstration purposes only */
body { padding: 70px; }
.triangle:hover { background: rgba(0,0,255,.5) }
.triangle:hover:before { background: rgba(255,0,0,.5) }
.triangle:hover:after { background: rgba(255,255,0,.5) }
<!-- content to be placed inside <body>…</body> -->
<div class='triangle'></div>

1 Comment

Yes, I did it and also did few changes, to rotate it. You can see it in comment.

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.