0

Please, take a look on this:

<div class="box photo col2 normaloffer">

Where the css (simplified) is like:

.box {
  margin: 5px;
  padding: 5px;
  font-size: 11px;
  line-height: 1.4em;
  float: left;
  border:1px solid #DFDFDF;
  -webkit-border-radius: 5px;
     -moz-border-radius: 5px;
          border-radius: 5px;
}

.normaloffer {
    background: #D8D5D2;
}

.col2 { width: 180px; }

That renders:

enter image description here

Well, I need to overlap an image at the top center of each image, I know that making some divs and arranging them I can do that, but I was wondering, can I make this using a class? because I want to overlap the image sometimes and sometimes not. Something like:

<div class="box photo col2 normaloffer OVERLAP">
.OVERLAP { // no idea what to put in here, is possible? }

EDIT Result: enter image description here

DomingoSL
  • 14,920
  • 24
  • 99
  • 173

1 Answers1

4

You could use the :after pseudo class to create an element after inside the div and place it with absolute positioning.

.overlap {
    position:relative;
}

.overlap:after {
    content:' ';
    position:absolute;
    top:0;
    left:60px;
    width:60px;
    height:60px;
    background:url("http://placekitten.com/60/60") no-repeat center center red;
}

enter image description here

See working example: http://jsfiddle.net/WpBKr/

amosrivera
  • 26,114
  • 9
  • 67
  • 76