Advertisement
pusatdata

CSS Trick: Create Infobox Colour

Jun 11th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. CSS:
  2. =====================================================================================
  3.  
  4. /* == START FOLDED CORNERS */
  5.  
  6. .note {
  7. position:relative;
  8. width:480px;
  9. padding:1em 1.5em;
  10. margin:2em auto;
  11. color:#fff;
  12. background:#97C02F;
  13. overflow:hidden;
  14. }
  15.  
  16. .note:before {
  17. content:"";
  18. position:absolute;
  19. top:0;
  20. right:0;
  21. border-width:0 16px 16px 0; /* This trick side-steps a webkit bug */
  22. border-style:solid;
  23. border-color:#fff #fff #658E15 #658E15; /* A bit more verbose to work with .rounded too */
  24. background:#658E15; /* For when also applying a border-radius */
  25. display:block; width:0; /* Only for Firefox 3.0 damage limitation */
  26. /* Optional: shadow */
  27. -webkit-box-shadow:0 1px 1px rgba(0,0,0,0.3), -1px 1px 1px rgba(0,0,0,0.2);
  28. -moz-box-shadow:0 1px 1px rgba(0,0,0,0.3), -1px 1px 1px rgba(0,0,0,0.2);
  29. box-shadow:0 1px 1px rgba(0,0,0,0.3), -1px 1px 1px rgba(0,0,0,0.2);
  30. }
  31.  
  32. .note.red {background:#C93213;}
  33. .note.red:before {border-color:#fff #fff #97010A #97010A; background:#97010A;}
  34.  
  35. .note.blue {background:#53A3B4;}
  36. .note.blue:before {border-color:#fff #fff transparent transparent; background:transparent;}
  37.  
  38. .note.taupe {background:#999868;}
  39. .note.taupe:before {border-color:#fff #fff #BDBB8B #BDBB8B; background:#BDBB8B;}
  40.  
  41. /* ROUNDED CORNERS VERSION
  42. * All modern browsers can produce this effect with a single pseudo-element.
  43. * However, they all have bugs (mainly to do with border-radius) that make this a bit tricky.
  44. * As far as I can tell, this is the only cross-browser method for the moment.
  45. * Cant use this method for the simple effect because Opera 11 will only show backgrounds
  46. * through transparent borders if there is a border-radius applied.
  47. */
  48.  
  49. .note.rounded {
  50. -webkit-border-radius:5px 0 5px 5px;
  51. -moz-border-radius:5px 0 5px 5px;
  52. border-radius:5px 0 5px 5px;
  53. }
  54.  
  55. .note.rounded:before {
  56. border-width:8px; /* Triggers a 1px 'step' along the diagonal in Safari 5 (and Chrome 10) */
  57. border-color:#fff #fff transparent transparent; /* Avoids the 1px 'step' in webkit. Background colour shows through */
  58. -webkit-border-bottom-left-radius:5px;
  59. -moz-border-radius:0 0 0 5px;
  60. border-radius:0 0 0 5px;
  61. }
  62.  
  63. .note p {margin:0;}
  64. .note p + p {margin:1.5em 0 0;}
  65. /* == END FOLDED CORNERS */
  66.  
  67.  
  68. HTML:
  69. ================================================================================
  70.  
  71. <div class="note">
  72. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris pulvinar rhoncus risus, vel ornare lacus sagittis sit amet. Duis vel sem magna. Proin pulvinar velit eleifend ligula ultrices vestibulum. Nunc posuere dolor eu mauris feugiat dignissim.</p>
  73. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris pulvinar rhoncus risus, vel ornare lacus sagittis sit amet. Duis vel sem magna. Proin pulvinar velit eleifend ligula ultrices vestibulum. Nunc posuere dolor eu mauris feugiat dignissim.</p>
  74. </div>
  75.  
  76. <div class="note red rounded">
  77. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris pulvinar rhoncus risus, vel ornare lacus sagittis sit amet. Duis vel sem magna. Proin pulvinar velit eleifend ligula ultrices vestibulum. Nunc posuere dolor eu mauris feugiat dignissim.</p>
  78. </div>
  79.  
  80. <div class="note blue">
  81. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris pulvinar rhoncus risus, vel ornare lacus sagittis sit amet. Duis vel sem magna. Proin pulvinar velit eleifend ligula ultrices vestibulum. Nunc posuere dolor eu mauris feugiat dignissim.</p>
  82. </div>
  83.  
  84. <div class="note taupe">
  85. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris pulvinar rhoncus risus, vel ornare lacus sagittis sit amet. Duis vel sem magna. Proin pulvinar velit eleifend ligula ultrices vestibulum. Nunc posuere dolor eu mauris feugiat dignissim.</p>
  86. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement