仿写小米官网 右边工具导航栏

说明:

1.由于本人只学习了部分html和css,所以本文没有涉及到js部分。
2.本文并没有实现小米官网首页的全部功能,还存在很多问题。如果以后技能提升,会继续更新实现未完成的功能。
3.这个练习会为分几篇文章介绍从最初分析到最后实现的代码,如果发现问题或者有更好的方法请联系本人探讨更正。
4.总体框架分析见博客 《仿写小米官网 简单的HTML+CSS练习》

目标:仿写小米官网的右侧工具导航栏:
在这里插入图片描述

HTML元素:

<div class="tool-bar">
            <ul>
                <li class="open-box">
                    <a href="#">
                        <img src="./img/tool-bar-img/1s.png" class="static">
                        <img src="./img/tool-bar-img/1h.png" class="hover">
                        <span>手机APP</span>
                        <div class="app-download" >
                            <img src="./img/tool-bar-img/downapp.png">
                            <span>扫码领取新人百元红包</span>
                        </div>
                    </a> 
                </li>
                <li>
                    <a href="#">
                        <img src="./img/tool-bar-img/2s.png" class="static">
                        <img src="./img/tool-bar-img/2h.png" class="hover">
                        <span>个人中心</span>
                    </a>    
                </li>
                <li>
                    <a href="#">
                         <img src="./img/tool-bar-img/3s.png" class="static">
                        <img src="./img/tool-bar-img/3h.png" class="hover">
                        <span>售后服务</span>
                    </a>
                </li>
                <li>
                    <a href="#">
                        <img src="./img/tool-bar-img/4s.png" class="static">
                        <img src="./img/tool-bar-img/4h.png" class="hover">
                        <span>人工客服</span>
                    </a>  
                </li>
                <li>
                    <a href="#">
                        <img src="./img/tool-bar-img/5s.png" class="static">
                        <img src="./img/tool-bar-img/5h.png" class="hover">
                        <span>购物车</span>
                    </a> 
                </li>
            </ul>
        </div>

CSS样式:
代码实现:

/* 首页右侧工具栏 */
    .tool-bar{
        width: 84px;
        height: 460px;
        position: fixed;
        bottom: 70px;
        right: 0;
        z-index: 999;
        background-color: white;
    }
    .tool-bar span{
        color: #9c9c9c;
    }
    .tool-bar ul{
        width: 100%;
        height: 100%;
    }
    .tool-bar li{
        width: 100%;
        height: 90px;
        border: 1px solid #f5f5f5;
        border-right: none;
    }
    .tool-bar li:hover span{
        color: #FF6A00;
    }
    .tool-bar li:hover .static{
        display: none;
    }
    .tool-bar li:hover .hover{
        display: block;
    }
    .tool-bar li img{
        width: 30px;
        height: 30px;
        margin-left: 27px;
        margin-top: 18px;
    }
    .tool-bar li .hover{
        display: none;
    }
    .tool-bar li span{
        display: inline-block;
        width: 100%;
        height: 14px;
        font-size: 14px;
        text-align: center;
    }
    .open-box::before{
        display: none;
        content: '';
        border: 8px solid transparent;
        border-left-color: white;
        position: absolute;
        left: -10px;
        top: 50%;
    }
    .open-box{    
        position: relative;
    }
    .open-box .app-download{
        display: none;
        position: absolute;
        z-index: 999;
        background-color: white;
        right: 94px; 
        padding: 14px;
        width: 100px;
        height: 161px;
        top: 0;
    }
    .open-box .app-download img{
        display: block;
        width: 100px;
        height: 100px;
        margin: 6px auto;
    }
    .open-box .app-download span{
        display: inline-block;
        width: 80px;
        margin-left: 10px;   
    }
    .open-box:hover::before{
        display: block;
    }
    .open-box:hover .app-download span{
        color: #9c9c9c;
    }
    .open-box:hover .app-download{
        display: block;
    }
  • 4
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 8
    评论
首先,你需要在你的电脑上安装 Visual Studio Code (VS Code)。 然后,按照以下步骤创建一个仿写小米官网的项目: 1. 打开 VS Code 并创建一个新的文件夹,命名为 "xiaomi-clone"(或者你喜欢的其他名字)。 2. 在 VS Code 中打开终端(Terminal)。在菜单栏中选择 "View" -> "Terminal",或使用快捷键 Ctrl + `。 3. 在终端中输入以下命令,创建一个新的 HTML 文件并进入文件夹: ``` mkdir xiaomi-clone cd xiaomi-clone touch index.html ``` 4. 在 VS Code 中打开 "index.html" 文件,并输入以下基本的 HTML 结构: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Xiaomi Clone</title> </head> <body> <!-- 这里放置页面内容 --> </body> </html> ``` 5. 在 `<body>` 标签内添加页面内容。你可以通过查看小米官网来获取页面布局和内容的灵感。使用 HTMLCSS 创建仿写页面结构和样式。 6. 在终端中输入以下命令,创建一个新的 CSS 文件并进入文件夹: ``` touch style.css ``` 7. 在 VS Code 中打开 "style.css" 文件,并添加你的样式代码。你可以使用 CSS 来设置页面的布局、字体、颜色等。 8. 在 "index.html" 文件的 `<head>` 标签中添加链接到 "style.css" 文件的代码: ```html <link rel="stylesheet" href="style.css"> ``` 9. 继续完善页面内容和样式,根据需要添加 JavaScript 代码来实现交互功能。 10. 最后,通过在浏览器中打开 "index.html" 文件来预览你的仿写小米官网项目。 这只是一个简单的指南,帮助你开始创建仿写小米官网的项目。你可以根据需要添加更多的页面和功能。祝你好运!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

格格不入ち

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值