2017-06-16 85 views
-1

我必須顯示圖標圖像,同時最小化窗口。調整屏幕大小時顯示圖像。但是,如果我最小化它並刷新頁面,圖像與桌面視圖菜單崩潰...它只適用於調整大小。在標籤或移動視圖中,如果我們刷新它,它與桌面視圖菜單搭配...我試着用媒體查詢too.but沒有結果。任何人指導我?如何顯示圖像,同時最小化窗口大小移動視圖

<img src="myPicture.png" id="imgid"> 

    media only screen and (max-width : 320px) 
    { 
     #imgid 
     { 
      display:inline-block; 
      position:absolute; 
     } 
//This is desktop view list item which needs to be hide under mypicture. 
     #ullist 
     { 
      display:none; 
     } 


    } 
+1

尋求幫助的問題(「**爲什麼不是,或如何使這個代碼工作?」)必須包含所需的行爲,_specific問題或錯誤以及**最短代碼** _在問題本身**中重現它**。沒有**明確問題陳述**的問題對其他讀者沒有用處。請參閱:[如何創建最小,完整和可驗證示例](http://stackoverflow.com/help/mcve)。 – LGSon

回答

0

試試這個代碼

@media only screen and (max-width: 320px) { 
 
    \t 
 
    #imgid 
 
    { 
 
      display: block; 
 
    } 
 
} 
 
@media only screen and (min-width: 420px) { 
 
    \t 
 
    #imgid 
 
    { 
 
      display: none; 
 
    } 
 
}
<img src="myPicture.png" id="imgid" width="100" height="100" >

0

通過身體標記之前放置腳本,它解決了問題。

相關問題