1

Is it possible with pure CSS (without images or sth. like that) to create square-cut corners.

Example:

.elem {
     border-radius:50%;
}

The above CSS creates a circle - very useful.

However I am searching for a possibility in CSS to create a diamond. Or just an element with cut-off corners. I thought about the transform property but maybe there is something to only cut of the corners instead of turning the whole element and turning its contents back?

3

1 Answer 1

2

Here is a working jsfiddle of a diamond : https://jsfiddle.net/h9xmtnma/

Important thing to remember is the ability of using this kind of notation

#diamond:after

which is very useful !

Hope it works for you ! :)

Edit : Here is the code.

#diamond {
width: 0;
height: 0;
border: 50px solid transparent;
border-bottom-color: red;
position: relative;
top: -50px;
}
#diamond:after {
content: '';
position: absolute;
left: -50px;
top: 50px;
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: red;
}  
Sign up to request clarification or add additional context in comments.

4 Comments

Solves part of the question however now I found a discussion which discusses the whole topic very nice.
Alright, hope you'll find what you need ! Do not hesitate to upvote though if it helped :) Have a good day !
You should add the relevant code to your answer. External links can die (or become unavailable for various reasons) and if you have a link-only answer, it becomes useless (a non-reachable answer basically)
Correct! This is done, thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.