Created
November 17, 2010 21:35
-
-
Save andyford/704137 to your computer and use it in GitHub Desktop.
CSS Triangle goofs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>undocumented title</title> | |
| <style> | |
| nav {display:block;} | |
| html { | |
| background: #eee; | |
| } | |
| body { | |
| width: 400px; | |
| margin: 10px auto; | |
| background: #fff; | |
| } | |
| h1 { | |
| text-align: center; | |
| margin: 0; | |
| } | |
| nav.main { | |
| position: relative; | |
| margin: 0 -10px; | |
| padding: 0 10px; | |
| background: #ccc; | |
| } | |
| nav.main ul { | |
| overflow: hidden; | |
| margin: 0; | |
| padding: 0; | |
| list-style: none; | |
| } | |
| nav.main li { | |
| float: left; | |
| } | |
| nav.main a { | |
| display: block; | |
| padding: 4px; | |
| color: #000; | |
| } | |
| nav.main:before, | |
| nav.main:after { | |
| display: block; | |
| position: absolute; | |
| top: 100%; | |
| width: 0; | |
| height: 0; | |
| content: ''; | |
| } | |
| nav.main:before { | |
| left: -10px; | |
| border-left: 10px solid transparent; | |
| border-bottom: 10px solid transparent; | |
| border-right: 10px solid #999; | |
| } | |
| nav.main:after { | |
| right: -10px; | |
| border-right: 10px solid transparent; | |
| border-bottom: 10px solid transparent; | |
| border-left: 10px solid #999; | |
| } | |
| #main { | |
| padding: 40px 10px; | |
| } | |
| .ribbon { | |
| position: relative; | |
| display: inline-block; | |
| padding: 2px 8px; | |
| background: #666; | |
| color: #fff; | |
| } | |
| .ribbon:before, | |
| .ribbon:after { | |
| display: block; | |
| position: absolute; | |
| top: 100%; | |
| width: 0; | |
| height: 0; | |
| content: ''; | |
| } | |
| .ribbon:before { | |
| left: -10px; | |
| border-left: 10px solid transparent; | |
| border-bottom: 10px solid transparent; | |
| border-right: 10px solid #444; | |
| } | |
| .ribbon:after { | |
| right: -10px; | |
| border-right: 10px solid transparent; | |
| border-bottom: 10px solid transparent; | |
| border-left: 10px solid #444; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="header"> | |
| <h1>CSS Triangle Goofs</h1> | |
| <nav class="main"> | |
| <ul> | |
| <li><a href="">home</a></li> | |
| <li><a href="">about</a></li> | |
| <li><a href="">contact</a></li> | |
| <li><a href="">etcetera</a></li> | |
| </ul> | |
| </nav> | |
| </div> | |
| <div id="main"> | |
| <div class="ribbon"> | |
| what | |
| </div> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment