-1

I have a logo behind a text and everytime i modified a margin from another div it's change the position. First is from PUG and 2nd is from css

.column(span="row")    
    h1.first-title Bmw M4 
    img(src="asset/image/M-emblem.png", alt="").icon__M 

img.icon__M{
        max-width: 80px;
        height: auto;
        position: absolute;
        z-index: 0;
        right: 107px;
        top: 177px;
    }

I used it the position absolute for icon and relative for the div and z-index to place logo behind the text

AndreiN
  • 47
  • 8
  • 1
    If the relative element has moved by a margin the absolute element's position will also change as per the relative element movement which is expected. Otherwise, change your approach as mentioned by @LaurentC in answer. – Vivek Vikranth Oct 13 '20 at 22:21

1 Answers1

0

Are you looking for something like this?

I use flexbox display to center the H1 text and background-image to add the logo.

.c {
  background-image:url('https://www.gamasutra.com/db_area/images/news/2018/Jun/320213/supermario64thumb1.jpg');
    background-position:center center;
  background-repeat:no;
  background-size:cover;
    height:200px;
    width:200px;
  display:flex;align-items:center;justify-content:center;
}
<div class="c">
  <h1>BMW X4</h1>
</div>

Codepen: https://codepen.io/larrytherabbit/pen/gOMaBYy

avia
  • 1,527
  • 7
  • 19