最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

@media 屏幕無法工作,出了什么問題?

@media 屏幕無法工作,出了什么問題?

RISEBY 2024-01-22 20:00:30
我有以下代碼,這是我從教程中獲得的。當(dāng)我在 Chrome 或 Firefox 上運行時,無論我是否調(diào)整窗口大小,都會顯示所有兩行。我究竟做錯了什么?<html><head>    <style>#content-desktop {display: block;}#content-mobile {display: none;}@media screen and (max-width: 768px) {#content-desktop {display: none;}#content-mobile {display: block;}</style><meta charset="UTF-8"><title>Untitled Document</title></head><div class="content-desktop">This is the content that will display on DESKTOPS.</div><div class="content-mobile">This is the content that will display on MOBILE DEVICES.</div><body></body></html>
查看完整描述

3 回答

?
萬千封印

TA貢獻(xiàn)1891條經(jīng)驗 獲得超3個贊

首先,您正在使用class="content-desktop"andclass="content-mobile"并且您的 CSS 是期望的,id因為您使用了#content-desktopand #content-mobile。


其次,您忘記關(guān)閉支架。


在 CSS 中,您需要使用點.來選擇class和#選擇id。


嘗試這個 :


.content-desktop {display: block;}

.content-mobile {display: none;}


@media screen and (max-width: 768px) {

   .content-desktop {display: none;}

   .content-mobile {display: block;}

}


查看完整回答
反對 回復(fù) 2024-01-22
?
絕地?zé)o雙

TA貢獻(xiàn)1946條經(jīng)驗 獲得超4個贊

您從未關(guān)閉括號,您正在使用 # 來定位您需要使用的類。而且你的 div 也在 body 標(biāo)簽之外。此外,在這種情況下,您還需要查詢上述縮放比例。下面的代碼經(jīng)過測試。你可以直接運行它。


<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width, initial-scale=1">

<style>

.desktop {

  background-color: yellow;

  padding: 20px;

}


@media screen and (max-width: 600px) {

  .desktop {

    display: none;

  }

  .mobile{

      background-color: red;

  padding: 20px;

}

}

@media screen and (min-width: 600px){

    .mobile{

        display: none;

    }

}

</style>

</head>

<body>


<h2>Hide elements on different screen sizes</h2>


<div class="desktop">Show on desktop but hide on mobile.</div>

<div class="mobile">Show on Mobile but hide on desktop</div>



</body>

</html>


查看完整回答
反對 回復(fù) 2024-01-22
?
不負(fù)相思意

TA貢獻(xiàn)1777條經(jīng)驗 獲得超10個贊

你永遠(yuǎn)不會關(guān)閉這里打開的括號:

@media screen and (max-width: 768px) {

因此,整個@media規(guī)則都會被解析器丟棄。只需在應(yīng)該關(guān)閉的地方關(guān)閉它(可能在 之前</style>)。


查看完整回答
反對 回復(fù) 2024-01-22
  • 3 回答
  • 0 關(guān)注
  • 321 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號