当前位置: 首页 > news >正文

免费做链接的网站吗如何注册域名网站

免费做链接的网站吗,如何注册域名网站,电商网站是获取流量,网站建设需要经过哪几个步骤使用场景 在生产环境中,遇到一个需求,需要在一个深色风格的大屏页面中,嵌入 Google Maps。为了减少违和感,希望地图四边能够淡出过渡。 这里的“淡出过渡”,关键是淡出,而非降低透明度。 基于 Google Ma…

使用场景

在生产环境中,遇到一个需求,需要在一个深色风格的大屏页面中,嵌入 Google Maps。为了减少违和感,希望地图四边能够淡出过渡。

这里的“淡出过渡”,关键是淡出,而非降低透明度。

基于 Google Maps 的深色示例中,附加上述需求,效果如下:

在这里插入图片描述

简单的说,就是中间放地图,四周放标题和其它展板内容。
在这里插入图片描述

CSS mask-image + SVG

简化一下,把地图换成图片,实现一个示例。

示例中,注释掉“mask”标记的内容,恢复“svg test”标记的内容,可以查看 svg 。

准备工作,定义一个“容器”和“目标”层:

<div id="container"><img id="target" src="https://cdn.pixabay.com/photo/2024/07/28/09/04/mountain-8927018_1280.jpg"><!-- svg test --><!-- <div id="target" style="width:1920px;height:1080px;"></div> -->
</div>

基础样式:

body {margin: 0;background-color: black;
}#container {position: absolute;width: 100%;height: 100%;background-repeat: repeat;display: flex;align-items: center;justify-content: center;
}#target {max-width: 80%;max-height: 80%;/* mask */-webkit-mask-mode: alpha;mask-mode: alpha;mask-repeat: no-repeat;mask-size: 100% 100%;/* svg test *//* background-repeat: no-repeat;background-size: 100% 100%; */
}

给“容器”添加一个波点背景,为了验证淡出过渡区域可以透视背景,这里直接用 svg 实现:

(function() {const container = document.querySelector('#container');const containerBg = `<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30"><circle fill="rgba(255,255,255,0.1)" cx="15" cy="15" r="10" /></svg>`;container.style.backgroundImage = `url('data:image/svg+xml;utf8,${encodeURIComponent(containerBg)}')`;// 略
})();

接着给“目标”准备一个处理方法,如果目标是一个图片,为了获得图片大小,将在图片的 onload 中执行:

(function() {// 略const target = document.querySelector('#target');function setTargetBg() {// 略}target.onload = setTargetBgsetTargetBg()
})();

为了实现淡出过渡效果,需要准备一个 svg:

分为 4+1 块,上下左右 4 个梯形 path,中间 1 个矩形 rect。
4 个梯形分别设置了 4 个方向的 linearGradient 渐变。

在这里插入图片描述

这里用代码绘制上面的 svg:

svg 的宽高是基于“目标”的宽高,淡入过渡区域大小 padding 基于“目标”短边的 20%。
特别地,patch 和 rect 中的加减“1”,目的是为了消除 path 之间的缝隙。

  function setTargetBg() {const svgWidth = target.offsetWidth,svgHeight = target.offsetHeight,padding = Math.floor(Math.min(target.offsetWidth, target.offsetHeight) * 0.2),fill = 'white',patch = 0.2;const targetMask = `<svg xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"width="${svgWidth}"height="${svgHeight}" viewBox="0 0 ${svgWidth} ${svgHeight}"><defs><linearGradient id="mask-bottom-to-top" x1="0" x2="0" y1="0" y2="1"><stop offset="0%" stop-color="transparent" /><stop offset="100%" stop-color="${fill}" /></linearGradient><linearGradient id="mask-top-to-bottom" x1="0" x2="0" y1="0" y2="1"><stop offset="0%" stop-color="${fill}" /><stop offset="100%" stop-color="transparent" /></linearGradient><linearGradient id="mask-rigth-to-left" x1="0" x2="1" y1="0" y2="0"><stop offset="0%" stop-color="transparent" /><stop offset="100%" stop-color="${fill}" /></linearGradient><linearGradient id="mask-left-to-right" x1="0" x2="1" y1="0" y2="0"><stop offset="0%" stop-color="${fill}" /><stop offset="100%" stop-color="transparent" /></linearGradient></defs><path fill="url(#mask-bottom-to-top)" d="M0,0 L${svgWidth},0 L${svgWidth - padding + patch},${padding + patch} L${padding - patch},${padding + patch} Z"></path><path fill="url(#mask-top-to-bottom)" d="M0,${svgHeight} L${padding - patch},${svgHeight - padding - patch} L${svgWidth - padding + patch},${svgHeight - padding - patch} L${svgWidth},${svgHeight} Z"></path><path fill="url(#mask-rigth-to-left)" d="M0,0 L${padding + patch},${padding} L${padding + patch},${svgHeight - padding} L0,${svgHeight} Z"></path><path fill="url(#mask-left-to-right)" d="M${svgWidth},0 L${svgWidth - padding - patch},${padding} L${svgWidth - padding - patch},${svgHeight - padding} L${svgWidth},${svgHeight} Z"></path><rect x="${padding - 1}" y="${padding - 1}" width="${svgWidth - padding * 2 + 1 * 2}" height="${svgHeight - padding * 2 + 1 * 2}" fill="${fill}"></rect></svg>
`;// masktarget.style.maskImage = `url('data:image/svg+xml;utf8,${encodeURIComponent(targetMask.replace(/\n/g, ''))}')`;// svg test// target.style.backgroundImage = `url('data:image/svg+xml;utf8,${encodeURIComponent(targetMask.replace(/\n/g, ''))}')`;}

最终效果:

在这里插入图片描述

在线Demo

http://www.dinnco.com/news/19658.html

相关文章:

  • 企业网站建设的主要步骤代运营
  • 网站建设规划书的空间360seo关键词优化
  • 广州地区做网站的关键词挖掘长尾词
  • 网站美工难做吗谷歌 翻墙入口
  • 建设一个微商的网站北大青鸟职业技术学院简介
  • 猪八戒网网站建设数据分析师培训机构
  • 呼和浩特市网站谷歌浏览器下载手机版官网
  • 网上营销的方式谷歌优化的网络公司
  • 网站的微信推广怎么做免费开发软件制作平台
  • 南宁网站设计运营快速排名软件seo系统
  • 网站常见程序问题站内seo是什么意思
  • 绛帐做企业网站百度关键词刷搜索量
  • 做门户网站服务器选择注册域名费用一般多少钱
  • wordpress站关注别人优化百度百科
  • 小企业网站建设方案谷歌浏览器 安卓下载2023版官网
  • 做网站优化好的网络公司网络营销主要做些什么工作
  • 双井网站建设经典品牌推广文案
  • 哪个网站在线做头像好腾讯广告投放平台官网
  • 北京网站制作推广软文营销文章
  • 长春阿凡达网站建设网络营销的优势包括
  • 做外贸怎么进入国外的网站常熟网络推广
  • 网站建设需要域名吗?网站seo优化建议
  • 西安做网站找哪家公司好营销网点机构号
  • 甘肃兰州区号关键词排名优化价格
  • 长春市住房和城乡建设局官网seo关键词排名价格
  • 珲春建设银行网站百度搜索智能精选入口
  • z-blog还是wordpress搜索引擎排名优化
  • 做暧暧视频免费网站app引导页模板html
  • 淘宝几百块钱做网站靠谱吗网站设计专业的公司
  • 淄博营销网站建设社区营销推广活动方案