大佬教程收集整理的这篇文章主要介绍了css – 根据设备方向更改图像,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有人可以添加一些简单的代码来帮助解决这个问题?
@media screen and (orientation: porTrait) { ... } @media screen and (orientation: landscapE) { ... }
使用这些媒体查询,您可以覆盖任何方向的背景图像.
官方文件:http://www.w3.org/TR/css3-mediaqueries/#orientation
有两种使用方法:
假设你有< div>使用类标题:
@media screen and (orientation: porTrait) { div.header { BACkground-image:url(image1.jpg); } } @media screen and (orientation: landscapE) { div.header { BACkground-image:url(image2.jpg); } }
或者,您可能希望使用< img>标签.在这种情况下,您将需要其中两个,并且只使用CSS规则隐藏/显示一个.让我们说,< img>标签分别有header-land和header-porTrait类:
@media screen and (orientation: porTrait) { .header-land { display:none; } .header-porTrait { display:inline-block; } } @media screen and (orientation: landscapE) { .header-land { display:inline-block; } .header-porTrait { display:none; } }
以上是大佬教程为你收集整理的css – 根据设备方向更改图像全部内容,希望文章能够帮你解决css – 根据设备方向更改图像所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。