84669 personnes étudient
152542 personnes étudient
20005 personnes étudient
5487 personnes étudient
7821 personnes étudient
359900 personnes étudient
3350 personnes étudient
180660 personnes étudient
48569 personnes étudient
18603 personnes étudient
40936 personnes étudient
1549 personnes étudient
1183 personnes étudient
32909 personnes étudient
css中有宽度百分百,若想达到高度占屏幕的百分百,宽度保持纵横比应该怎么做呢, 希望详细解答,嘻嘻
如果你指的是背景图的话... background-size: auto 100%; 会是你想要的效果的。
background-size: auto 100%;
推荐看看MDN对background-size的解释
虽然也想能够详细回答,但是爱莫能助啊,不知道你要什么,需要什么。
background: url(../images/main1_bg.jpg) no-repeat center center; background-size:cover; background-attachment: fixed;我以前写的,这里的background-size:100% 100%;估计可以,但比例会失真。我现在用的办法都是把img设置为absolute,top:0;left:50%; height:100%; 然后在标签上写<img ... onload="setPos(this)">然后这个setpos函数写在js文件里,function setpos(ts){ var w=ts.width/2; ts.style.margin="0 0 0 -"+w+"px"; } 这个函数会在图片加载完成后执行,让图片水平居中。
如果你指的是背景图的话...
background-size: auto 100%;
会是你想要的效果的。推荐看看MDN对background-size的解释
虽然也想能够详细回答,但是爱莫能助啊,不知道你要什么,需要什么。
background: url(../images/main1_bg.jpg) no-repeat center center;
background-size:cover;
background-attachment: fixed;
我以前写的,这里的background-size:100% 100%;估计可以,但比例会失真。
我现在用的办法都是把img设置为absolute,top:0;left:50%; height:100%; 然后在标签上写<img ... onload="setPos(this)">
然后这个setpos函数写在js文件里,function setpos(ts){ var w=ts.width/2; ts.style.margin="0 0 0 -"+w+"px"; } 这个函数会在图片加载完成后执行,让图片水平居中。