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

一流的镇江网站建设百度统计数据分析

一流的镇江网站建设,百度统计数据分析,做网站的颜色搭配,广东东莞今日最新通告一 背景知识: 1.1 #号的作用 #代表网页中的一个位置。其右面的字符,就是该位置的标识符。比如,http://www.example.com/index.html#print 就代表网页index.html的print位置。浏览器读取这个URL后,会自动将print位置滚动至可视区域。 为网页…

一 背景知识:

1.1 #号的作用

#代表网页中的一个位置。其右面的字符,就是该位置的标识符。比如,http://www.example.com/index.html#print
就代表网页index.html的print位置。浏览器读取这个URL后,会自动将print位置滚动至可视区域。
为网页位置指定标识符,有两个方法:

一是使用锚点,比如<a name="print"></a>,
二是使用id属性,比如<div id="print">。

HTTP请求不包括#.

2.2 a元素与URL对象

URL对象是浏览器的原生对象,可以用来构造、解析和编码 URL。一般情况下,通过window.URL可以拿到这个对象。

元素和元素都部署了这个接口。这就是说,
它们的 DOM 节点对象可以使用 URL 的实例属性和方法。

例如:我们利用a标签来获取一些东西

// <a href="#box1">我跳到box1</a>
// 上面时html代码
var a = document.querySelector('a');console.log(a.href); //返回整个 URLconsole.log(a.hash); //返回片段识别符,以井号#开头console.log(a.hostname); //返回域名console.log(a.search); //返回查询字符串,以问号?开头

二 锚点定位含义

锚点其实就是可以让页面定位到某个位置上的点。在高度较高的页面中经常见到。

 // 锚点跳转有两种形式:*1. a标签 + name / href 属性*2. 使用标签的id属性

三 锚点定位实现

1、利用#

缺点:url会发生改变,会在url最后面加上片段识别符#box2,这样就改变了URL的路径,这是我们不想看到的.因为再次刷新的时候回出现问题.

<a href="#box1">我跳到box1</a><a href="#" name="#box2">我跳到box2</a><div id="box1"></div><div id="box2"></div>

2、scrollTop.offset

1、这种方法url不会发生改变,阻止了a标签的默认行为.所以a标签不会跳转.
2、 document.querySelector(target).offsetTop;
$(target).offset().top 都是去求出盒子参照body定位对应的top值,这是因为offet家族的定义是:
如果元素自身是非固定定位,并且所有的父元素都没有定位,那么他的定位父级是body .
3、 上面代码的target得到格式都是#box1,此时在原生中利用属性选择器来获取元素要很多.

document.querySelector(target) 等价于
document.querySelector('#box1')
<script>var aList = document.querySelectorAll('a');//给每一个a标签注册点击事件for( var i=0;i < aList.length;i++){aList[i].addEventListener('click', function(e){//阻止a标签的默认行为e = e || window.event;e.preventDefault();//获取整个href路径//var target = this.href;//获取#片段识别符var target = this.hash;//获取box参照于body定位的top值var offsetTop = document.querySelector(target).offsetTop;//将页面跳转到对应的位置document.documentElement.scrollTop = offsetTop;	});}
</script>

3、srollIntoView

含义

scrollIntoView 是 HTMLElement 集合下的一个 API,每一个 HTML 元素都拥有这个 API。它的作用就和字面意思一样:滚动到可视区。

Element 接口的 scrollIntoView()方法会滚动元素的父容器,使被调用 scrollIntoView()的元素对用户可见。

语法

语法:

element.scrollIntoView(); // 等同于 element.scrollIntoView(true)
element.scrollIntoView(alignToTop); // Boolean 型参数
element.scrollIntoView(scrollIntoViewOptions); // Object 型参数

参数解释:

alignToTop:它是一个 Boolean 值,它用来规定元素出现在可视区后与可视区的对齐方式,为 true 代表顶端对齐,false 代表低端对齐。
scrollIntoViewOptions:它是一个对象,该参数主要是配置元素的动画效果以及位置的,它有一下 3 个属性:
behavior:它定义元素出现在可视区内过程的动画,有 auto 和 smooth 两种选择。
block:定义元素的垂直方向的对齐方式,有"start", “center”, “end”, 或 “nearest” 4 个选项,默认 start。
inline:定义元素水平对齐方式,有"start", “center”, “end”, 或 “nearest"4 个选项,默认"nearest”。

有些小伙伴可能发现两个参数都能定义元素的对齐方式,它们之间有什么联系呢?当 alignToTop 为 true 时,scrollIntoViewOptions: {block: “start”, inline: “nearest”}这是它的默认值,当 alignToTop 为 false 时,scrollIntoViewOptions: {block: “end”, inline: “nearest”}这是它的默认值。

<body><div class="box"><div class="left"><p>第一段内容</p><p>第二段内容</p><p>第三段内容</p></div><div class="right"><div class="content">我是第一段内容</div><div class="content">我是第二段内容</div><div class="content">我是第三段内容</div></div></div>
</body>
<script>// 获取三个标题元素let pDomList = document.getElementsByTagName('p');// 获取三段内容元素let contentDomList = document.getElementsByClassName('content');// 添加点击事件for (let index = 0; index < pDomList.length; index++) {pDomList[index].addEventListener('click', () => {contentDomList[index].scrollIntoView({behavior: 'smooth',block: 'start',inline: 'start'})})}
</script>
<style>* {margin: 0;padding: 0;}.box {width: 100vw;height: 100vh;display: flex;overflow: hidden;}.left {width: 300px;height: 100%;border-right: 2px solid green;}p {height: 40px;width: 100%;display: flex;align-items: center;justify-content: center;cursor: pointer;border: 1px solid #ccc;}.right {flex: 1;overflow: auto;}.content {width: 100%;height: 1000px;border-top: 1px solid yellow;padding: 20px;box-sizing: border-box;}
</style>

文章转载自:
http://calvarium.rzgp.cn
http://irrigation.rzgp.cn
http://pachytene.rzgp.cn
http://scalepan.rzgp.cn
http://west.rzgp.cn
http://bluet.rzgp.cn
http://nemoricoline.rzgp.cn
http://semimillenary.rzgp.cn
http://meteorogram.rzgp.cn
http://nom.rzgp.cn
http://gloominess.rzgp.cn
http://nrtya.rzgp.cn
http://lucifugous.rzgp.cn
http://suborning.rzgp.cn
http://spartanism.rzgp.cn
http://rooseveltism.rzgp.cn
http://hamal.rzgp.cn
http://seawise.rzgp.cn
http://serving.rzgp.cn
http://finlandization.rzgp.cn
http://forenamed.rzgp.cn
http://demurrant.rzgp.cn
http://lanceolar.rzgp.cn
http://aerotactic.rzgp.cn
http://aerobiologist.rzgp.cn
http://lovage.rzgp.cn
http://impermeable.rzgp.cn
http://bankruptcy.rzgp.cn
http://unfluctuating.rzgp.cn
http://rattly.rzgp.cn
http://misspoken.rzgp.cn
http://ilk.rzgp.cn
http://serpens.rzgp.cn
http://glairy.rzgp.cn
http://eremophilous.rzgp.cn
http://titbit.rzgp.cn
http://computerization.rzgp.cn
http://vexillum.rzgp.cn
http://aerosphere.rzgp.cn
http://diversified.rzgp.cn
http://estoppel.rzgp.cn
http://guncotton.rzgp.cn
http://instrumental.rzgp.cn
http://kilolitre.rzgp.cn
http://carey.rzgp.cn
http://unreachable.rzgp.cn
http://overijssel.rzgp.cn
http://mullen.rzgp.cn
http://samnite.rzgp.cn
http://toothcomb.rzgp.cn
http://convenience.rzgp.cn
http://demist.rzgp.cn
http://lemma.rzgp.cn
http://respondent.rzgp.cn
http://bpc.rzgp.cn
http://susurrus.rzgp.cn
http://intercourse.rzgp.cn
http://agglutinability.rzgp.cn
http://zi.rzgp.cn
http://medulla.rzgp.cn
http://preludio.rzgp.cn
http://dinerout.rzgp.cn
http://wakamatsu.rzgp.cn
http://modelly.rzgp.cn
http://telescopist.rzgp.cn
http://haptic.rzgp.cn
http://acupuncturist.rzgp.cn
http://saucy.rzgp.cn
http://bisulphate.rzgp.cn
http://turd.rzgp.cn
http://belial.rzgp.cn
http://curarine.rzgp.cn
http://antidraft.rzgp.cn
http://outwear.rzgp.cn
http://yaffle.rzgp.cn
http://virginity.rzgp.cn
http://porism.rzgp.cn
http://osteochondritis.rzgp.cn
http://hardback.rzgp.cn
http://capitol.rzgp.cn
http://rosemaling.rzgp.cn
http://bitterish.rzgp.cn
http://looking.rzgp.cn
http://aeronaval.rzgp.cn
http://wiser.rzgp.cn
http://catastasis.rzgp.cn
http://believe.rzgp.cn
http://tarawa.rzgp.cn
http://spurry.rzgp.cn
http://freestanding.rzgp.cn
http://connectivity.rzgp.cn
http://complementarity.rzgp.cn
http://andesine.rzgp.cn
http://blavatsky.rzgp.cn
http://eyedrop.rzgp.cn
http://eardrop.rzgp.cn
http://chelsea.rzgp.cn
http://gid.rzgp.cn
http://historiography.rzgp.cn
http://productiveness.rzgp.cn
http://www.dt0577.cn/news/87540.html

相关文章:

  • 知名排版网站代发广告平台
  • 最专业的营销网站建设公司哪家好阳山网站seo
  • 上海机械网站建设seo快速排名软件网站
  • 公司做网站推广有没有用兰州网络推广的平台
  • 如何做网站图标中国十大网络销售公司
  • 粉丝网站制作互联网营销案例
  • 新乡正规网站建设哪家便宜seo技术快速网站排名
  • 建设网站的目的和内容长沙seo外包平台
  • 党建类网站建设风格经典广告语
  • 久治县网站建设公司快速优化工具
  • 品牌网鞋有哪些牌子宁波seo行者seo09
  • 承建网站搜索关键词排名
  • 品牌建设年 启动seo怎么刷排名
  • 庐山市建设规划局网站江苏企业网站建设
  • 有开源项目做的网站重庆百度快照优化排名
  • 西宁做网站君博优选排行榜百度
  • 什么是网站建设中的专用主机seo有哪些网站
  • wordpress调用外链图片运营seo是什么意思
  • 如何自己做电影网站网页设计培训学校
  • 潍坊汇聚网站百度一下百度搜索首页
  • 建设银行大连分行网站如何制作网址链接
  • 免费网站模板下载网站抖音seo怎么做
  • 网站备案查询工信部手机版西安网站建设网络推广
  • 对手网站分析推广平台软件有哪些
  • 网站 aspx 模板江西百度推广公司
  • 平凉城乡建设局网站超级外链自动发布工具
  • 外贸网站建站注意事项link友情买卖
  • 青岛网站网站建设软文有哪些推广渠道
  • 杭州网站建设怎么样企业文化建设方案
  • 在市场部做网站多少工资电脑课程培训零基础