大家好,欢迎来到freecodecamp HTML专题第10篇。

今天的挑战依然关于a标签。

背景知识
a元素除了可以指向外部的一个网站之外,同样也可以用来跳转到网站内部的某一个区域。这一点大家都应该体会过,当我们看一篇长文博客,我们经常通过点击小标题的方式超链接到文章当中具体的位置。

想要创建一个内部的链接,同样需要使用href这个属性,我们将它设置成'#'加上具体的id的形式来实现。这里的id是HTML当中的一个通用属性,任何标签都可以加上id。id作为一个标识符,可以作为CSS样式的设置目标,也可以作为a标签的跳转目标。需要注意的是对于每一个元素赋予的id都应该是唯一的。

下面我们展示一个通过id完成内部跳转的例子:

<a href="#contacts-header">Contacts</a>...<h2 id="contacts-header">Contacts</h2>

我们给h2标签赋予了一个id属性,当我们点击a标签的时候,它就会跳转到这个id标记的区域。

题意
通过修改href属性的值将网站当中外部的标签修改成内部的标签'#footer',并且把对应的文本从"cat photos"改成"Jump to Bottom"。

移除a标签中target=_blank属性,因为它会使得用户在点击链接的时候打开一个新的页面。

之后在<footer>标签当中加上一个为"footer"的id属性。

要求

  • 网站当中只能有一个a标签
  • 网站当中只能有一个footer标签
  • a标签需要有一个指向"#footer"的href属性
  • a标签不能有target属性
  • a标签的文本应该为"Jump to Bottom"
  • footer标签需要有一个为"footer"的id属性
    编辑器
<h2>CatPhotoApp</h2><main>  <a href="https://freecatphotoapp.com" target="_blank">cat photos</a>  <img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back.">  <p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff. Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched. Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>  <p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched. Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff. Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>  <p>Meowwww loved it, hated it, loved it, hated it yet spill litter box, scratch at owner, destroy all furniture, especially couch or lay on arms while you're using the keyboard. Missing until dinner time toy mouse squeak roll over. With tail in the air lounge in doorway. Man running from cops stops to pet cats, goes to jail.</p>  <p>Intently stare at the same spot poop in the plant pot but kitten is playing with dead mouse. Get video posted to internet for chasing red dot leave fur on owners clothes meow to be let out and mesmerizing birds leave fur on owners clothes or favor packaging over toy so purr for no reason. Meow to be let out play time intently sniff hand run outside as soon as door open yet destroy couch.</p></main><footer>Copyright Cat Photo App</footer>

解答
今天的挑战很简单,其实就是按照设置内部跳转的方式来修改一下html代码。主要分为三个步骤,一个步骤是在footer标签当中加上我们跳转的目标,也就是id属性。接着在a标签当中修改跳转的目标,从外部的链接改成内部的id。最后我们改一下a标签的文本信息即可。

<h2>CatPhotoApp</h2><main>  <a href="#footer">Jump to Bottom</a>  <img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back.">  <p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff. Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched. Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>  <p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched. Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff. Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>  <p>Meowwww loved it, hated it, loved it, hated it yet spill litter box, scratch at owner, destroy all furniture, especially couch or lay on arms while you're using the keyboard. Missing until dinner time toy mouse squeak roll over. With tail in the air lounge in doorway. Man running from cops stops to pet cats, goes to jail.</p>  <p>Intently stare at the same spot poop in the plant pot but kitten is playing with dead mouse. Get video posted to internet for chasing red dot leave fur on owners clothes meow to be let out and mesmerizing birds leave fur on owners clothes or favor packaging over toy so purr for no reason. Meow to be let out play time intently sniff hand run outside as soon as door open yet destroy couch.</p></main><footer id="footer">Copyright Cat Photo App</footer>

想要亲自动手尝试一下的同学不要忘了点击文末的阅读原文进行跳转哦~

文章就到这里,给个三连再走吧~

©著作权归作者所有:来自51CTO博客作者wx6087db7ed1cb2的原创作品,如需转载,请注明出处,否则将追究法律责任

你的鼓励让我更有动力

赞赏

0人进行了赞赏支持

更多相关文章

  1. 小白前端入门笔记(12),设置哑链接
  2. 小白前端入门笔记(七),HTML5中的main标签
  3. 原创 | matplotlib绘图教程,设置标签与图例
  4. 把一个"结构体"当做属性后碰到的问题
  5. 实例演示,v-if,v-for,v-model,v-bind,v-on,计算属性和侦听器属性
  6. 使用 IntraWeb (21) - 基本控件之 TIWTabControl
  7. 使用 IntraWeb (20) - 基本控件之 TIWGrid
  8. Delphi 正则表达式之TPerlRegEx 类的属性与方法(7): Split 函数
  9. 在 Delphi 中使用微软全文翻译的小例子

随机推荐

  1. 如何用Python读取Excel中图片?又如何用Pyt
  2. 动画:老大,不好了,内存泄漏了!
  3. 设计这样一场面试,绝了!
  4. k8s网络之Calico
  5. 小伙爬取CSDN博客TOP100榜单,发现高玩博主
  6. Android(安卓)之 使用VideoView播放视频
  7. android实现推特Twitter分享
  8. 数据结构之优先队列和堆
  9. 项目经理小姐姐非要给我讲一讲,项目开发规
  10. 尝鲜!微软首个AI量化投资开源平台Qlib上手