background: url(../images/main1_bg.jpg) no-repeat center center; background-size:cover; background-attachment: fixed; I wrote it before, here background-size: 100% 100%; probably OK, but the proportion will be distorted. The method I use now is to set img to absolute, top:0;left:50%; height:100%; and then write <img ... onload="setPos(this)"> on the label ; Then this setpos function is written in the js file, function setpos(ts){ var w=ts.width/2; ts.style.margin="0 0 0 -"+w+"px"; } This function It will be executed after the image is loaded to center the image horizontally.
If you are referring to the background image...
background-size: auto 100%;
It will have the effect you want.It is recommended to read MDN’s explanation of background-size
Although I would like to be able to answer in detail, I am helpless. I don’t know what you want or need.
background: url(../images/main1_bg.jpg) no-repeat center center;
background-size:cover;
background-attachment: fixed;
I wrote it before, here background-size: 100% 100%; probably OK, but the proportion will be distorted.
The method I use now is to set img to absolute, top:0;left:50%; height:100%; and then write <img ... onload="setPos(this)"> on the label ;
Then this setpos function is written in the js file, function setpos(ts){ var w=ts.width/2; ts.style.margin="0 0 0 -"+w+"px"; } This function It will be executed after the image is loaded to center the image horizontally.