URL中的CSS选择器 [英] CSS selector in the URL

查看:131
本文介绍了URL中的CSS选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当你有这样一个url www.example.com/#signup 时,浏览器所做的只是将它的视图集中在id为注册,是吗?

When you have a url like this www.example.com/#signup, what the browser does is just to focus it's view on the HTML element with id signup, is that right?

如果以这种方式聚焦元素,是否可以更改元素的CSS样式?

Is it possible to change the element's CSS style if it's focused in that way?

Eg 假设我有一个div元素,id 注册,那么如果我输入 www.example.com ,div的背景为白色,如果输入 www.example.com/#signup 它是黄色的。就像强调注册表单一样。这是可能的吗?

E.g. let's say I have a div element, with the id signup, then if I enter www.example.com, the div's background is white and if I enter www.example.com/#signup it's yellow. Like "emphasizing" the sign up form. Is this at all possible?

推荐答案

:target { background-color: yellow; }

:target psuedo-class does正是这个。

The :target psuedo-class does exactly this.

这篇关于URL中的CSS选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆