Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bend a div with CSS

Tags:

css

webkit

Is it possible to bend a div with CSS?

Some sort of webkit transform...

The effect i want to create is a have a ring doughnut shape but made up of a curved div as opposed to border-radius/border tricks

EDIT:

Use case - I'd like to put a linear gradient on this div and have the gradient wrap back around on itself, like in the game Snake, where it chases it tail...

like image 780
benhowdle89 Avatar asked Dec 15 '11 23:12

benhowdle89


People also ask

How do I create a curve in the middle of a div border in CSS?

you can use pseudo elements The border radiuses. The relative/absolute position combination of both elements, with the half-circle (absolute position) being the child of the rectangle. The left and transform settings of the half-circle for the horizontal position in the center.

How do I make an arc in CSS?

It's possible to draw circles and arcs in CSS by simply creating a square <div> and setting border-radius to 50%. Each side of the border can take a different color or can be set to transparent . The background-color property sets the shape's fill, if any.

How do you make an oval shape in CSS?

CSS is capable of making all sorts of shapes. Squares and rectangles are easy, as they are the natural shapes of the web. Add a width and height and you have the exact size rectangle you need. Add border-radius and you can round that shape, and enough of it you can turn those rectangles into circles and ovals.


1 Answers

Currently, this is not possible with CSS alone. Your best bet would be to make use of the canvas (and some Javascript).

https://developer.mozilla.org/en/Drawing_Graphics_with_Canvas

http://www.roblaplaca.com/examples/bezierBuilder/

like image 81
matthewpavkov Avatar answered Oct 06 '22 00:10

matthewpavkov