Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS items with border radius and triangle side

Tags:

css

css-shapes

Is it possible in css (without images) make items with border radius and triangle side?

li items

like image 774
Oleg Pasko Avatar asked Sep 19 '12 17:09

Oleg Pasko


2 Answers

You can use an SVG image that will render sharply at any size and will adapt to the element's size, it would look like this...

.button {
  background: #000;
  float: left;
  position: relative;
  color: #999;
  font: 15px/130% Arial, sans-serif;
  padding: 10px 20px;
  clear: both;
  margin: 10px;
  border-radius: 5px 0 0 5px;
}

.button:after {
  content: '';
  display: block;
  width: 10px;
  position: absolute;
  right: -10px;
  height: 100%;
  top: 0;
  background: transparent url('triangle.svg') 0 0 no-repeat;
}

http://jsfiddle.net/Ch7aA/

​This jsfiddle will only work in Webkit because I've inlined the svg so you can understand how it works, but if you load it from an external file it should work fine. Here's the rendering for reference:

enter image description here

like image 118
methodofaction Avatar answered Sep 25 '22 14:09

methodofaction


have a look at this: http://css-tricks.com/snippets/css/css-triangle/ or this: http://jonrohan.me/guide/css/creating-triangles-in-css/

for the dynamic height, there is a question and answer here: CSS triangle with dynamic height

like image 38
Kristóf Dombi Avatar answered Sep 24 '22 14:09

Kristóf Dombi