项目场景:
内网机使用静态网页,导航图标不显示
问题描述:
网上找了一个静态导航网页,在本机打开正常,局域网打开后不显示图标
正常效果预览
源码地址
源码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>自适应布局导航栏</title>
<link href="https://cdn.bootcss.com/font-awesome/5.8.0/css/all.css" rel="stylesheet" />
<style>
* {
margin: 0;
padding: 0;
font-family: 'montserrat', sans-serif;
box-sizing: border-box;
}
.services-section {
background: #333;
background-size: cover;
padding: 60px 0;
}
.inner-width {
width: 100%;
max-width: 1200px;
margin: auto;
padding: 0 20px;
overflow: hidden;
}
.section-title {
text-align: center;
color: #ddd;
text-transform: uppercase;
font-size: 30px;
}
.border {
width: 160px;
height: 2px;
background: #82ccdd;
margin: 40px auto;
}
.services-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.service-box {
max-width: 33.33%;
padding: 10px;
text-align: center;
color: #ddd;
cursor: pointer;
}
.service-icon {
display: inline-block;
width: 70px;
height: 70px;
border: 3px solid #82ccdd;
color: #82ccdd;
transform: rotate(45deg);
margin-bottom: 30px;
margin-top: 16px;
transition: 0.3s linear;
}
.service-icon i {
line-height: 70px;
transform: rotate(-45deg);
font-size: 26px;
}
.service-box:hover .service-icon {
background: #82ccdd;
color: #ddd;
}
.service-title {
font-size: 18px;
text-transform: uppercase;
margin-bottom: 10px;
}
.service-desc {
font-size: 14px;
}
@media screen and (max-width: 960px) {
.service-box {
max-width: 45%;
}
}
@media screen and (max-width: 768px) {
.service-box {
max-width: 50%;
}
}
@media screen and (max-width: 480px) {
.service-box {
max-width: 100%;
}
}
</style>
</head>
<body>
<div class="services-section">
<div class="inner-width">
<h1 class="section-title">Our Service</h1>
<div class="border"></div>
<div class="services-container">
<div class="service-box">
<div class="service-icon">
<i class="fas fa-paint-brush"></i>
</div>
<div class="service-title">Web Design</div>
<div class="service-desc">
做过电商项目的同学都知道,店铺装修是电商系统必备的一个功能,在某些场景下,可能是广告页制作、活动页制作、微页面制作,但基本功能都是类似的。所谓店铺装修,就是用户可以在
PC端进行移动页辑,属于用户高度自定义的功能。最终编辑的结果。
</div>
</div>
<div class="service-box">
<div class="service-icon">
<i class="fas fa-brush"></i>
</div>
<div class="service-title">Web Design</div>
<div class="service-desc">
做过电商项目的同学都知道,店铺装修是电商系统必备的一个功能,在某些场景下,可能是广告页制作、活动页制作、微页要通过简单的拖拽就可以实现页面的编辑,属于用户高度自定义的功能。最终编辑的结果。
</div>
</div>
<div class="service-box">
<div class="service-icon">
<i class="fas fa-object-ungroup"></i>
</div>
<div class="service-title">Web Design</div>
<div class="service-desc">
做过电商项目的同学都知道,店铺装修是电商系统必备的一个功能,在某些场景下,可能是广告页制作、活动页制作、微页面制作,但基本功能都是拖拽就可以实现页面的编辑,属于用户高度自定义的功能。最终编辑的结果。
</div>
</div>
<div class="service-box">
<div class="service-icon">
<i class="fas fa-paint-brush"></i>
</div>
<div class="service-title">Web Design</div>
<div class="service-desc">
PC端进行移动页面的制作,只需要通过简单的拖拽就可以实现页面的编辑,属于用户高度自定义的功能。最终编辑的结果。
</div>
</div>
<div class="service-box">
<div class="service-icon">
<i class="fas fa-database"></i>
</div>
<div class="service-title">Web Design</div>
<div class="service-desc">
做过电商项目的同学都知道,店铺装修是电商系统必备的一个功能,在某些场景下,可能是广告页制作、活动页制。所谓店铺装修,就是用户可以在
PC端进行移动页面的制作,只需要通过简单的拖拽就可以实现页面的编辑,属于用户高度自定义的功能。最终编辑的结果。
</div>
</div>
<div class="service-box">
<div class="service-icon">
<i class="fab fa-android"></i>
</div>
<div class="service-title">Web Design</div>
<div class="service-desc">
做过电商项目的同学都知道,店铺装修是电商系统必备的一个功能,在某些场景下,可能是广告页制作、活动页制作、微页面制作,但基本需要通过简单的拖拽就可以实现页面的编辑,属于用户高度自定义的功能。最终编辑的结果。
</div>
</div>
</div>
</div>
</div>
</body>
</html>
原因分析:
html加载了一个在线的css
<!-- font-awesome -->
<link href="https://cdn.bootcss.com/font-awesome/5.8.0/css/all.css" rel="stylesheet" />
css 分析
@font-face {
font-family: 'Font Awesome 5 Brands';
font-style: normal;
font-weight: 400;
font-display: block;
src: url("../webfonts/fa-brands-400.eot");
src: url("../webfonts/fa-brands-400.eot?#iefix") format("embedded-opentype"), url("../webfonts/fa-brands-400.woff2") format("woff2"), url("../webfonts/fa-brands-400.woff") format("woff"), url("../webfonts/fa-brands-400.ttf") format("truetype"), url("../webfonts/fa-brands-400.svg#fontawesome") format("svg"); }
.fab {
font-family: 'Font Awesome 5 Brands';
font-weight: 400; }
@font-face {
font-family: 'Font Awesome 5 Free';
font-style: normal;
font-weight: 400;
font-display: block;
src: url("../webfonts/fa-regular-400.eot");
src: url("../webfonts/fa-regular-400.eot?#iefix") format("embedded-opentype"), url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.woff") format("woff"), url("../webfonts/fa-regular-400.ttf") format("truetype"), url("../webfonts/fa-regular-400.svg#fontawesome") format("svg"); }
.far {
font-family: 'Font Awesome 5 Free';
font-weight: 400; }
@font-face {
font-family: 'Font Awesome 5 Free';
font-style: normal;
font-weight: 900;
font-display: block;
src: url("../webfonts/fa-solid-900.eot");
src: url("../webfonts/fa-solid-900.eot?#iefix") format("embedded-opentype"), url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.woff") format("woff"), url("../webfonts/fa-solid-900.ttf") format("truetype"), url("../webfonts/fa-solid-900.svg#fontawesome") format("svg"); }
.fa,
.fas {
font-family: 'Font Awesome 5 Free';
font-weight: 900; }
css中使用了../webfonts/
的url
显而易见,内网是无法访问该css及css引用的文件
解决方案:
下载 fontawesome-free-5.15.3-web.zip
关注即可下载
修改css引用路径
将css及webfonts拷贝至相应目录
对应目录结构示意,多余的文件可不用拷贝
├─css
│ all.css
└─webfonts
fa-brands-400.eot
fa-brands-400.svg
fa-brands-400.ttf
fa-brands-400.woff
fa-brands-400.woff2
fa-regular-400.eot
fa-regular-400.svg
fa-regular-400.ttf
fa-regular-400.woff
fa-regular-400.woff2
fa-solid-900.eot
fa-solid-900.svg
fa-solid-900.ttf
fa-solid-900.woff
fa-solid-900.woff2
备注:
因为不熟悉html以及css的开发,只是做一个简单静态页面
走了很多弯路,在解决了问题以后找到了大佬的gitee 学到了很多,大家一起学习!