2010-08-26 67 views

回答

1

这在CSS中很容易做到。您可以使用媒体查询将CSS应用于某些方向。我们通过两种方式做到这一点,有时我们将更改<div>的背景图像,否则我们将有两个<img>标签,并只设置一个我们不想显示的标签display:none下面是示例代码,用于设置div的背景id ='funky'

<style type="text/css"> 
    @media only screen and (orientation:portrait){ 
     #funky { 
     background-image: url(http://path/to/your/image1.png) 
     }   
    } 
    @media only screen and (orientation:landscape){ 
     #funky { 
     background-image: url(http://path/to/your/other/image2.png) 
     }   
    } 
</style> 
相关问题