Reputation: 45
I have this sample:
.header{
background-image:url("http://orange.motorcitynewengland.com/img/bg/jeep-renegade.jpg");
width:1920px;
height:616px;
background-size:contain;
}
span{
font-size: 21px;
color: white;
position: absolute;
left: 56%;
transform: rotate(33deg);
top: 86px;
}
<div class="header">
<span>Low mileage</span>
</div>
I want to keep the element position regardless of the browser size. You please tell me how to do this?
Thanks in advance!
Upvotes: 1
Views: 4074
Reputation: 808
if the inner element is absolute, outer element must be relative to position relative to outter element.
.header{
background-image:url("http://orange.motorcitynewengland.com/img/bg/jeep-renegade.jpg");
width:1920px;
height:616px;
background-size:contain;
position: relative;
}
span{
font-size: 21px;
color: white;
position: absolute;
left: 56%;
transform: rotate(33deg);
top: 86px;
}
<div class="header">
<span>Low mileage</span>
</div>
Upvotes: 0
Reputation: 660
.header{
background-image:url("http://orange.motorcitynewengland.com/img/bg/jeep-renegade.jpg");
width:1920px;
height:616px;
background-size:contain;
}
span{
font-size: 19px;
color: white;
position: absolute;
left: 105%;
transform: rotate(33deg);
top: 10%;
}
<div class="header">
<span>Low mileage</span>
</div>
Upvotes: 1
Reputation: 9738
You must change the unit from % to px left: 650px
.header{
background-image:url("http://orange.motorcitynewengland.com/img/bg/jeep-renegade.jpg");
width:1920px;
height:616px;
background-size:contain;
}
span{
font-size: 21px;
color: white;
position: absolute;
left: 650px;
transform: rotate(33deg);
top: 86px;
}
Upvotes: 1