3

I want to be able to create a transparent background using only CSS but with an angle on one end. I've found various ways of trying to do it, but can't quite get it. I don't really want to use any scripting, just CSS.

Background image would need to look like this:

square with slanted side

web-tiki
  • 92,319
  • 29
  • 210
  • 241
RustyIngles
  • 2,366
  • 4
  • 26
  • 30

1 Answers1

9

You could do it using borders: http://jsfiddle.net/wNhjb/

#shape {
   height: 0; 
   width: 80px;
   border-top: 80px solid blue;
   border-left: 40px solid transparent;
}

Alex
  • 6,096
  • 1
  • 19
  • 26
  • @Alex do you happen to know how cross browser this is? Does IE render it the same way? – ug_ Mar 02 '14 at 06:37
  • @ns47731 I never tested it, but this should be the behavior defined in the standards. So it *should* look the same in every more or less standard-compliant browser. – Alex Mar 12 '14 at 07:31