首页 > 其他分享 >网页布局-----头部设置和头部悬浮显示内容

网页布局-----头部设置和头部悬浮显示内容

时间:2024-05-07 11:44:57浏览次数:26  
标签:font 网页 height content header ----- 头部 icon before

小米商城官网地址小米商城 - Xiaomi 14 Ultra、Redmi K70、MIX FOLD 3,小米电视官方网站

一、头部

1、效果图

2、网页结构

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小米官网</title>
    <link rel="stylesheet"  href="./header.css" >
    <link rel="stylesheet" href="./iconfont.css">
    <link rel="stylesheet" href="./mi.css">
    <link rel="stylesheet" href="./reset.css">
    <link rel="icon" href="./images/favicon.ico" >
</head>
<body>
    <div class="header">
        <div class="content">
            <div class="header-left">
                <ul class="header-left-ul">
                    <li><a href="#">小米商城</a><span>|</span></li>
                    <li><a href="#">MIUI</a><span>|</span></li>
                    <li><a href="#">loT</a><span>|</span></li>
                    <li><a href="#">云服务</a><span>|</span></li>
                    <li><a href="#">星天数科</a><span>|</span></li>
                    <li><a href="#">有品</a><span>|</span></li>
                    <li><a href="#">小爱开放平台</a><span>|</span></li>
                    <li><a href="#">企业团购</a><span>|</span></li>
                    <li><a href="#">资质证照</a><span>|</span></li>
                    <li><a href="#">协议规则</a><span>|</span></li>
                    <li class="header-download"><a href="#">
                        下载app</a><span>|</span>
                        <div class="header-download-div">
                            <img  src="./images/78c30d4f259ed43ab20e810a522a6249.png" />
                            <span>小米商城APP</span>
                        </div>
                    
                    </li>
                    <li><a href="#">智能生活</a><span>|</span></li>
                    <li><a href="#">Select Location</a><span>|</span></li>
                </ul>
            </div>
            <div class="header-right">
                <ul class="header-right-ul">
                    <li><a href="#">登录</a><span>|</span></li>
                    <li><a href="#">注册</a><span>|</span></li>
                    <li><a href="#">消息通知</a><span>|</span></li><span>|</span>
                    <li class="shop-li">
                        <a href="#">
                            <i class="iconfont">&#xe653;</i>购物车(0)
                            <div class="shop-div">
                                <span>购物车中还没有商品,赶紧选购吧!</span>
                            </div>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</body>
</html>

 

3、css样式

/* 头部 */
*{
    margin: 0;
    padding: 0;
}
/* 头部设置 */
.header{
    width: 100%;
    height: 40px;
    background-color: #333;

}
.content{
    width: 1226px;
    height: 40px;
    margin: 0 auto;
    text-align: center;
    line-height: 40px;
}
li{
    list-style-type: none;
}
.content a{
    text-decoration: none;
    color: #b0b0b0;
    font-size: 12px;
}
.content a:hover{
    color: white;
}
.header-left{
    float: left;
}
.header-right{
    float: right;
}
.header-left-ul>li{
    float: left;
}
.header-right-ul>li{
    float: left;
}
.content li span{
    color: #424242;
    margin: 0 6px;
}
.shop-li{
    background-color: #424242;
    margin-left: 25px;
    width: 120px;
    height: 40px;
    position: relative;
}
.shop-li i{
    margin-right: 4px;
}
.shop-li:hover{
    background-color: white;
    cursor: pointer;
}
.shop-li:hover>a>font{
    color: coral;
}
/* 头部下拉设置 */

.header-download{
    position: relative;

}
.header-download-div{
    position: absolute;
    top: 40px;
    left: 50%;
    margin-left: -62px;
    width: 124px;
    height: 0;
    overflow: hidden;
    background-color: white;
    box-shadow: 0px 1px  5px #aaa;
    transition: all .3s;
}
.header-download-div img{
    width: 90px;
    height: 90px;
    margin: 18px auto 12px;
    display: block;

}
.header-download-div span{
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    display: block;
    padding-bottom: 10px;
}
.header-download:hover >.header-download-div{
    height: 150px;
}
/* 购物车显示 */
.shop-div{
    position: absolute;
    right: 0px;
    top:40px;
    width: 316px;
    height: 0;
    background-color: white;
    box-shadow: 0px 2px 10px rgba(0, 0, 0, .15);
    text-align: center;
    line-height: 80px;
    overflow: hidden;
    transition: all .3s;
}
.shop-li:hover >a> .shop-div{
    height: 80px;
}

4、问题

1、悬浮到购物车文字上时,文字自动变为白色,在页面中查看源代码多出了font需要在悬浮显示内容中设置在a后面

2、左右两边都有数据时,需要设置两个div包裹起来使用float定位分别设置left和right,里面的数据在设置为float:left浮动,如果不设置两个div直接对数据设置左右浮动那么右侧数据将会反过来

3、经过头部标题显示的内容通过定义高度来显示,不是通过display设置。将显示内容的区域height设置为0 ,将显示手动内容通过overflow:hidden隐藏起来在经过标题时设置高度显示,设置transition实现加载的动画,设置box-shadow阴影将内容边框显示出来

4、购物车图片是引入进来的代码如下,通过class设置iconfont来引用

@font-face {font-family: "iconfont";
  src: url('iconfont.eot?t=1548064192113'); /* IE9 */
  src: url('iconfont.eot?t=1548064192113#iefix') format('embedded-opentype'), /* IE6-IE8 */
  url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAA+gAAsAAAAAG3AAAA9QAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCFfgqkbJ1pATYCJANcCzAABCAFhG0HgjIb8xYz0lHSygnZ/yGBGzKhPtSXQUK0JdFIprZadjSVfSM10vjmWFwKGx5fLFiwy1dQ6Ofu322244ZjhlJeT3P+vnsXu4vcxQmaVNBSJFSCBUhCNWJQ0WlSpSZQCRVTpBpqaul36v4hCG/3+xVwogs4wTgKLcKEA31JYAHQ5ucD/zd1VsAHvt3DVKL1acf1Q7ItO4lSRyoNvdvrBWm7u1CNwHgVxWYikZrI3e9l8wjSepyqAG8ukUkNEEQ8AziY3P/fWmqBi3uvwoRKLExelaxRM4fzd//27YQnxBOeCxZRMQhZy3sbgk2KpIBV6sjWmRqpC6lrHMSvYV23RFSD4daOWcEsLJw8z7qtewMEgBIlCTo+3pAAH4nqCF1uXLUE8LlspMSD8DdwBaN2hOZa8Nu0dhnAHPbn0Q978AEInAR6X/brxeXAWNwyFpj4zJke9wQATOwAMIAkAOTELKH1J2Cg1TyM2rjbDaIw5PHFxaUSTSdRrrZcivnVxJRexi+LVaTGy9ZmHUV7SgUSZcTqUhtKkJSY7CX/mYeJiCmRKDQ5IT4FFg8HQYBLRoIhBWgF0lkIANCGJiWo5e6XAQRqFcsABrVKDiKgChzEwGjoANSBAwmMBwcKmAAONDARHOTAbHAQAnPAgQ/MBQ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7rQMVygcRkBuNpFRiJwcpj1gbstoZk0NpVWPkv1lUBwMK327pP0QVhCQrqqYbpmU7rudjScnIKSipqMPzWDLG5VFyPJOwoBXq5HiU2xyd0nIwxJI4nEwHPUmOklroiMr7F4uqgHLg7EsmmV2NAzftPpE+i5hYEoxpsboSUWnSla43WeywzL7AvGZh/xehXhYEEV9lj5RsvMf4JrVUGo9aHOYy9D582ukLWrohver0ZY9xCIvL5kejAQAAAA==') format('woff2'),
  url('iconfont.woff?t=1548064192113') format('woff'),
  url('iconfont.ttf?t=1548064192113') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
  url('iconfont.svg?t=1548064192113#iconfont') format('svg'); /* iOS 4.1- */
}

.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-15tianwuliyoutuihuo:before {
  content: "\e606";
}

.icon-liwu:before {
  content: "\e657";
}

.icon-iconfonticon5:before {
  content: "\e615";
}

.icon-shouji01:before {
  content: "\e622";
}

.icon-gouwuche:before {
  content: "\e653";
}

.icon-icon:before {
  content: "\e666";
}

.icon-zhizhen:before {
  content: "\e64d";
}

.icon-jiantou2:before {
  content: "\e63e";
}

.icon-youjiantou:before {
  content: "\e658";
}

.icon-buoumaotubiao46:before {
  content: "\e629";
}

.icon-jiantouyou:before {
  content: "\e62a";
}

.icon-fangdajing:before {
  content: "\e63d";
}

.icon-jiantou:before {
  content: "\e616";
}

.icon-jiantou_zuo:before {
  content: "\e617";
}

.icon-duihua:before {
  content: "\e710";
}

.icon-dianhuaqia:before {
  content: "\e733";
}

.icon-chongzhijilu:before {
  content: "\e64c";
}

.icon-gouwuche1:before {
  content: "\e735";
}

.icon-kefu:before {
  content: "\e6ab";
}

.icon-liwu1:before {
  content: "\e62b";
}

.icon-qitianwuliyoutuihuan:before {
  content: "\e63f";
}

.icon-F:before {
  content: "\e61f";
}

 

二、

标签:font,网页,height,content,header,-----,头部,icon,before
From: https://www.cnblogs.com/lixianhui/p/18176961

相关文章

  • 哈希基础知识学习-python版
    哈希哈希表根据key直接进行访问的无序数据结构,复杂度为O(1)哈希表的实现---字典初始化d1=dict()查找#使用中括号[]进行查找,括号内为特定的键,键-值dic={"a":1,"d":0,"e":3}print(dic["a"])#输出1print(dic["z"])#报错修改dic["a"]=5print(dic[&quo......
  • 两个事务方法导致异常抛出Transaction rolled back because it has been marked as ro
    异常现场(背景)在springboot事物操作开发中,如果A方法调用B方法,A和B方法都在不同的类中,且A和B都加了@Transactional注解,A调用B方法时,将B方法trycatch了。代码:@ServicepublicclassBService{@Transactional(rollbackFor=Exception.class)publicvoidb......
  • Canvas简历编辑器-我的剪贴板里究竟有什么数据
    Canvas图形编辑器-我的剪贴板里究竟有什么数据在这里我们先来聊聊我们究竟应该如何操作剪贴板,也就是我们在浏览器的复制粘贴事件,并且在此基础上聊聊我们在Canvas图形编辑器中应该如何控制焦点以及如何实现复制粘贴行为。在线编辑:https://windrunnermax.github.io/CanvasEdito......
  • 九龙城寨之围城下载/迅雷BT[HD-1280P/2.21GB/MP4中字]4k中字已更新
    《九龙城寨之围城》是一部以真实历史事件为背景的电影,讲述了1967年香港发生的九龙城寨事件。该片通过精彩的剧情、真实的场景和生动的角色,再现了当时发生的种种困境与挑战。影片不仅展示了九龙城寨的社会环境和居民生活,更呈现了人性的复杂与光辉。 电影以九龙城寨......
  • 前来挑战!应急响应靶机训练-Web1
    前言应急响应靶机训练,为保证每位安服仔都有上手的机会,不做理论学家,增加动手经验,可前来挑战应急响应靶机-web1,此系列后期会长期更新,关注本公众号,被动学习。隔日会发题解,请大家务必关注我们。挑战内容前景需要:小李在值守的过程中,发现有CPU占用飙升,出于胆子小,就立刻将服务器关......
  • 动态判断两个时间的时间间隔--时分秒
    <!--div--><view>{{countRunTime(fromTime,toTime,'hh时mm分')"}}</view><!--script-->countRunTime(date1,date2,pattern){//date1开始时间,date2结束时间,pattern显示格式(这里只需要显示经时时分秒格式)letstartTime=newDate(date1......
  • 475-便携式手提RapidIO协议光纤发包测试仪
    便携式手提RapidIO协议光纤发包测试仪一、平台简介   便携式手提RapidIO协议光纤发包仪,以RapidIO收发卡和X86主板为基础,构建便携式的手提设备。   RapidIO收发卡是以KU060PCIeX4的双路QSFP+光纤收发卡,支持双路RapidIOX4数据的收发设计。   ......
  • unplugin-auto-import 工程项目 import 模块自动导入
    渡一(袁老师)视频详解[点击前往]unplugin-auto-import是一个用于**Vue3**(和Vue2的CompositionAPI)的插件,它可以自动导入你在代码中使用的VueCompositionAPI函数(如ref,reactive,computed等)以及来自其他库的函数(如VueRouter的useRoute,useRouter,或者Pinia的de......
  • A Revisiting Study of Appropriate Offline Evaluation for Top-N Recommendation Al
    目录概实验设置EvaluationMetricsMetric的一致性不同的metrics导致的算法排名差异SampledmetricsSampledmetrics是否会导致和fullranking的metrics不同的评价数据集构建数据集的选择和预处理\(k\)-corefiltering的影响数据集的切分数据集的切分方式对结果的影响数据......
  • ssrf-基于Pikachu的学习
    SSRFSSRF漏洞原理攻击与防御(超详细总结)-CSDN博客原理服务端请求伪造(ServerSideRequestForgery,SSRF)指的是攻击者在未能取得服务器所有权限时,利用服务器漏洞以服务器的身份发送一条构造好的请求给服务器所在内网。SSRF攻击通常针对外部网络无法直接访问的内部系统。比如......