- Simple floating CSS code box with rounded corners, a triangle and a shadow box:
I encountered this similar problem and after many disappointments, this is where I ended up.
See the script here: http://jsfiddle.net/erikthedeveloper/CASJY/
Essentially, I have a div.quote-box that contains p and two divs (.q-tip and .q-blocker).
I rotate the βtipβ to create a triangle. Place it exactly in the center at the bottom of the quote box and βblockβ the top half of the tip with my .blocker div. This leaves a nice shadow around the quote box and clues.
HTML
<div class="quote-box"> <p> "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit, deleniti fugit quo tempora cupiditate in! Esse, consectetur adipisicing elit. Impedit, deleniti fugit quo tempora cupiditate in! Esse, excepturi..." </p> <div class='q-tip q-rotate q-shadow'></div> <div class="q-blocker"></div> </div> </div>
CSS
.quote-box{ position: relative; width:100%; height: 150px; background-color: #fff; -moz-border-radius: 5px; -webkit-border-radius: 5px; -khtml-border-radius: 5px; border-radius: 5px; } .quote-box p{ width: 90%; margin: 1.5em auto; font-size: 0.85em; font-style: italic; line-height: 1.75em; color: #636363; max-height: 200px; overflow: hidden; padding-top: 10px; } .quote-box-tip{ font-size: 2em; position: relative; height: 1em; width: 0; left:45%; bottom:.5em; } .q-shadow, .quote-box{ -moz-box-shadow: 1px 1px 2px 0 #000; -webkit-box-shadow: 2px 2px 2px 0 #000; box-shadow: 1px 1px 2px 0 #000; } .q-tip{ height:20px; width:20px; background-color:#fff; position:absolute; bottom:-10px; left:0; right: 0; margin: auto; z-index:1; } .q-blocker{ width:80%; height:20px; background-color:#fff; position:absolute; bottom:0; z-index:2; left: 0; right: 0; margin: auto; } .q-rotate{ -webkit-transform: rotate(-45deg); -moz-transform: rotate(-45deg); -ms-transform: rotate(-45deg); -o-transform: rotate(-45deg); transform: rotate(-45deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0.5); }
I hope this helps!
source share