国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

製作一個(gè)響應(yīng)式的下拉式選單的方法
P粉521013123
P粉521013123 2023-09-04 15:47:42
0
2
755
<p>漢堡選單圖示應(yīng)該在右側(cè),圖片應(yīng)該在左側(cè)。 </p> <p>當(dāng)我們點(diǎn)擊選單打開時(shí),它應(yīng)該會(huì)展開一個(gè)下拉選單,裡面應(yīng)該會(huì)有l(wèi)ogo home <em>About us</em> gallery contact。 </p> <pre class="brush:html;toolbar:false;"><div class="rectangle1"> <ul class="dropdown"> <li class="li1"><a href="home.html"><img class="img" src="YOGI Logo.svg" alt=""> </a></li> <li class="li2"><a class="a1" href="#home">Home</a></li> <li class="li3"><a class="a2" href="aboutus.html">關(guān)於我們</a></li> <li class="li4"><a class="a3" href="gallery.html">圖庫</a></li> <li class="li5"><a class="a4" href="contact.html">聯(lián)絡(luò)我們</a></li> <a class="Contact_Us" href="contact.html"> <img class="Contact-us-img"src="Vector.svg" alt=""> <span class="Contact-us-text">聯(lián)絡(luò)我們</span> </a> </ul> </div> </pre> <p>我只需要將其轉(zhuǎn)換為CSS。 </p> <p>我需要它來適應(yīng) iPhone 14 Pro 的響應(yīng)式設(shè)計(jì),以成為漢堡菜單。 </p>
P粉521013123
P粉521013123

全部回覆(2)
P粉748218846

我認(rèn)為這可能對你有幫助:CSS @media Rule。正如你在教程中所看到的,CSS有一種方法可以檢查螢?zāi)坏膶挾取?

@media only screen and (max-width: 600px) {
  body {
    background-color: lightblue;
  }
}

在這個(gè)例子中,當(dāng)寬度小於600像素時(shí),背景顏色將被設(shè)定為淺藍(lán)色。使用這個(gè)規(guī)則,你可以相應(yīng)地改變你的CSS。

你應(yīng)該嘗試自己實(shí)現(xiàn)它,而不僅僅是從網(wǎng)路上複製貼上。去嘗試,享受使用CSS的樂趣;這是學(xué)習(xí)它的唯一方法。

P粉738821035

這是修改後的CSS程式碼,用於實(shí)現(xiàn)響應(yīng)式漢堡選單:

CSS(styles.css):

body {
    margin: 0;
    font-family: Arial, sans-serif;
}

header {
    background-color: #333;
    color: #fff;
    padding: 10px;
    display: flex;
    align-items: center;
}

.container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    color: #fff;
    text-decoration: none;
    font-size: 24px;
}

.menu-toggle {
    width: 30px;
    height: 30px;
    background-color: #fff;
    cursor: pointer;
    display: none; /* 在較大屏幕上默認(rèn)隱藏菜單圖標(biāo) */
}

.menu-toggle::before, .menu-toggle::after {
    content: "";
    display: block;
    width: 100%;
    height: 3px;
    background-color: #333;
}

.menu {
    display: flex;
    align-items: center;
}

.menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

.menu li {
    padding: 10px;
}

.menu a {
    color: #fff;
    text-decoration: none;
    font-size: 18px;
}

/* 移動(dòng)設(shè)備的媒體查詢 */
@media only screen and (max-width: 767px) {
    .menu {
        display: none; /* 在小屏幕上默認(rèn)隱藏菜單 */
        flex-direction: column;
        background-color: #333;
        position: absolute;
        top: 50px;
        right: 0;
        width: 100%;
    }

    .menu.active {
        display: flex; /* 激活時(shí)顯示菜單 */
    }

    .menu li {
        width: 100%;
        text-align: center;
    }

    .menu-toggle {
        display: block; /* 在小屏幕上顯示菜單圖標(biāo) */
    }
}
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板