Reputation: 481
I have a layout that looks like this, from using background-position: center
and background-size: cover
:
The original image is from here:
I would like for the first example to look more like this:
To do this I am imagining putting an anchor point on the image and somehow telling CSS to use this anchor point.
background-position: x y;
Wondering how I could accomplish this.
I don't want to crop the image, as when the screen is resized, or on mobile for example, it will show more of the image. I want the image to be as is. I also don't want the image squished, I want it to work like background-size: cover
works roughly, but with a custom anchor point.
Upvotes: -1
Views: 763
Reputation: 545
div.relative {
background: url(mountain.jpg);
background-repeat: no-repeat;
background-size: auto;
position: relative
top: //what you want e.g. 20px
left: //e.g. 40px;
bottom: //e.g. 80px;
right: //e.g. 0px;
}
Upvotes: 0