Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overlaying a <div> with text

Tags:

html

css

I need to be able to display price tags on a div.

like this

enter image description here

I am sure it's something to do with z index and positioning.

like image 602
kjehfiuh Avatar asked Sep 03 '15 12:09

kjehfiuh


1 Answers

maybe you could rethink your structure and use the flex properties.

You could something of that kind see snippet below (or breakable into 2 rows of three)

div {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 1em 3em;
  background: tomato;
}
figure {
  position: relative;
  display: table;
  height: 50px;
  width: 100px;
  margin: 2em;
}
figure img {
  position: absolute;
  transform:rotate(-10deg);
}
figcaption {
  display: table-cell;
  text-align: center;
  vertical-align: middle;
  color: white;
  position: relative;
}
<div>
  <figure>
    <img src="http://dummyimage.com/100x50/555/555">
    <figcaption>
      200€</figcaption>
  </figure>

  <figure>
    <img src="http://dummyimage.com/100x50/555/555">
    <figcaption>
      200€</figcaption>
  </figure>

  <figure>
    <img src="http://dummyimage.com/100x50/555/555">
    <figcaption>
      200€</figcaption>
  </figure>

  <figure>
    <img src="http://dummyimage.com/100x50/555/555">
    <figcaption>
      200€</figcaption>
  </figure>

  <figure>
    <img src="http://dummyimage.com/100x50/555/555">
    <figcaption>
      200€</figcaption>
  </figure>

  <figure>
    <img src="http://dummyimage.com/100x50/555/555">
    <figcaption>
      200€</figcaption>
  </figure>
</div>

think: witout CSS i must be able to understand what it is about ... you did separate image and price, not a really good idea ;)

like image 139
G-Cyrillus Avatar answered Oct 14 '22 04:10

G-Cyrillus