Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <div class="item">
  2. <img src="test.jpg" />
  3. <div class="overlay">
  4. <a href="#">Some long content</a>
  5. </div>
  6. </div>
  7.  
  8. .item {
  9. position: relative;
  10.  
  11. img {
  12. position: relative;
  13. z-index: 1;
  14. }
  15.  
  16. .overlay {
  17. position: absolute;
  18. z-index: 2;
  19. top: 0;
  20. right: 0;
  21. bottom: 0;
  22. left: 0;
  23. background: rgba(0,0,0,.5);
  24. text-align: center;
  25.  
  26. a {
  27. color: #fff;
  28. }
  29. }
  30. }
  31.  
  32. .item {
  33. display: table;
  34.  
  35. .overlay {
  36. display: table-cell;
  37. vertical-align: middle;
  38. }
  39. }
  40.  
  41. .item .overlay:before {
  42. content:" ";
  43. display:inline-block;
  44. vertical-align:middle;
  45. height:100%;
  46. }
  47. .item .overlay a {
  48. display:inline-block;
  49. vertical-align:middle;
  50. color: #fff;
  51. }
  52.  
  53. <div class="item">
  54. <img src="http://placehold.it/350x150.jpg" />
  55. <div class="overlay">
  56. <div class="inner-container">
  57. <div class="inner-cell">
  58. <a href="#">Some long content</a>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63.  
  64. .item {
  65. position: relative;
  66. width: 350px;
  67. display: table;
  68. }
  69. .item .overlay {
  70. position: absolute;
  71. z-index: 2;
  72. top: 0;
  73. right: 0;
  74. bottom: 0;
  75. left: 0;
  76. background: rgba(0,0,0,.5);
  77. text-align: center;
  78. width: 100%;
  79. height:100%;
  80. vertical-align: middle;
  81. }
  82. .inner-container{
  83. width: 100%;
  84. height: 100%;
  85. display:table;
  86. }
  87. .inner-cell {
  88. display:table-cell;
  89. vertical-align: middle;
  90. text-align: center;
  91. }
  92. .item .overlay a {
  93. color: #fff;
  94. }
  95.  
  96. .item .overlay{
  97. top:50%;
  98. -webkit-transform:translateY(-50%);
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement