I have submiited an image with a badge inside another badge and i am trying to figure out how they did it?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
- Adding a timeout to a render function in ReactJS
Explanation
In order to achieve the desired behavior, use the property
position: relative
in your wrapper element and useposition: absolute
in the child element.Then position the child element in the top/right corner with
top: 0
andright: 0
.The last part will require the CSS3 property
transform
with thetranslate
attribute. You can read more about it inCSS3 2D Transforms
ortransform | CSS-Tricks
.We will use
transform: translate(50%, -50%)
here. The first50%
means that the element will be dislocated half it's own width to the right, and the second50%
means that the element will be dislocated half it's own height up.You could skip this part if your badge has a fixed width and/or height, and just use a fixed value.
Example