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
  • 99,765
  • 32
  • 217
  • 249
RustyIngles
  • 2,433
  • 4
  • 27
  • 31

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,276
  • 2
  • 20
  • 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