Make image over div, like stamp
Make image over div, like stamp
I have div and want to put image like stamp to right top corner over div
Here is code what I already done
.package-item-header {
margin-top:20px;
margin-left:20px;
width: 200px;
background-color: #efefef;
text-align: center;
font-size: 24px;
position: relative;
padding: 20px;
}
.package_stamp{
height: 30px;
width: 30px;
background: url('https://i.imgur.com/bPR0GVD.png') 50px no-repeat;
background-position: center;
position:absolute;
top:0;
right:0;
}
GOLD
</div>
But it's just put it to right bottom corner of div, not over div.
How I can make it like this, but with transparent background?
Screen
3 Answers
3
You can move the image over its parent by using negative top
and right
values in combination with position: absolute
. overflow:visible
ensures the image to be visible beyond the parent's borders, but is not neccessary in this case.
top
right
position: absolute
overflow:visible
I also added background-size: cover
in order to make the background-image fill out the element.
background-size: cover
.package-item-header {
margin-top: 20px;
margin-left: 0;
width: 200px;
background-color: #efefef;
text-align: center;
font-size: 24px;
position: relative;
padding: 20px;
overflow: visible;
float: left;
}
.package_stamp {
height: 60px;
width: 60px;
background: url('https://i.imgur.com/bPR0GVD.png') 50px no-repeat;
background-position: center;
position: absolute;
top: -20px;
right: -20px;
background-size: cover;
z-index: 1;
}
GOLD
GOLD
GOLD
ah, z-index, I solve problem
– John Doe
Jun 29 at 10:21
Check this out http://jsfiddle.net/xpvt214o/328587/
.package_stamp{
height: 60px;
width: 60px;
background: url('https://i.imgur.com/bPR0GVD.png') 10px no-repeat;
background-position: center;
background-size: 60px 60px;
position:absolute;
top:5;
right:0;
}
right bottom corner???!!!
– Joseph Stalin
Jun 29 at 10:25
.package-item-header {
margin-top:20px;
margin-left:20px;
width: 100px;
background-color: #efefef;
text-align: center;
font-size: 24px;
position: relative;
padding: 20px;
position: relative;
float: left;
}
.package-item-header:hover .package_stamp {
opacity: .5;
}
.package_stamp{
height: 80px;
width: 80px;
background: url('https://i.imgur.com/bPR0GVD.png') no-repeat;
background-position: center;
position:absolute;
top:-25px;
right:-25px;
background-size: contain;
z-index: 1;
}
img.package_stamp {
border: 1px solid white;
}
GOLD</div>
GOLD</div>
GOLD</div>
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Yeah, it helps, but if I had 3 columns , I have this imgur.com/a/seFaBk1
– John Doe
Jun 29 at 10:20