B
B
Berkutman2018-09-20 12:42:21
css
Berkutman, 2018-09-20 12:42:21

How to keep original size of background-image?

Hello. there is a bscreen, adapted it to each screen size via @media requests
But the thing is that you have to adjust it with padding parameters.
How to do it. What would it shrink for each screen size, but keep its size?
Here's what I came across. Everything is fine on mobile, there is a different image.

/*Фон главная */

.headerbk{
     
    
  background-repeat: no-repeat;          

background-size: cover;
box-shadow:1px -20px 29px 0px rgba(52,62,89,0.71)inset;
-webkit-box-shadow:1px -20px 29px 0px rgba(52,62,89,0.71)inset;
-moz-box-shadow:1px -20px 29px 0px rgba(52,62,89,0.71)inset;
    background-attachment: scroll;
}



@media (min-width: 320px) {   
.headerbk {     
    background-image: url(../img/gv.png);
    padding-bottom: 26rem;
    padding-top: 11px;

  
    	} 
}

@media (min-width: 360px) {   
.headerbk {     
    background-image: url(../img/gv.png);
    padding-bottom: 30rem;
    padding-top: -5rem;
    background-size: cover;
    background-attachment: scroll;
      padding-top: 0px;
  
    	} 
}


@media (min-width: 480px) {   
.headerbk {     
background-image:url(../img/gv.png);
    	} 
}

@media (min-width: 767px) {   
.headerbk {     
background-image:url(../img/1.jpg); 
    padding-bottom: 30rem;  
    	} 
}



@media (min-width: 1024px) {   
.headerbk {background-image:url(../img/1.jpg);  
margin-top: 140px;
} 
}	



@media (min-width: 1280px)  {   
    background-image: url(../img/1.jpg);
    padding-top: 6rem;
    margin-top: 140px;
} 
}	

@media (min-width: 1366px)  {   
.headerbk {background-image:url(../img/1.jpg);  
padding-top: 10rem;  
margin-top: 140px;
} 
}	

@media (min-width: 1440px)  {   
.headerbk {background-image:url(../img/1.jpg);  
padding-top: 10rem;  
margin-top: 140px;
} 
}	


@media (min-width: 1600px)  {   
.headerbk {background-image:url(../img/1.jpg);  
    padding-top: 14rem;
    margin-top: 176px;
    padding-bottom: 31rem;
} 
}	

@media (min-width: 1920px)  {   
.headerbk {background-image:url(../img/1.jpg);  
padding-top: 20rem;  
margin-top: 176px;
} 
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dicem, 2018-09-20
@dicem

I'm not sure that I understood the question correctly, but is it about? background-size: contain;

R
Roman Filippov, 2018-09-20
@Webram

narrowed itself, but retained its size?

Excellent wording, maybe you mean the aspect ratio?
If so, then you need to make a block with a background of a fixed size (or fix its proportions), and then
background-size: contain;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question