Home > Web Front-end > Front-end Q&A > How to set the background of the link being visited with css

How to set the background of the link being visited with css

青灯夜游
Release: 2023-01-11 09:19:24
Original
1811 people have browsed it

In css, you can use the ":active" selector and background attribute to set the background of the link you are visiting. You only need to add "a:active{background:color value/url('picture url'" to the link );}" style can set the background color or background image of the link when it is being accessed.

How to set the background of the link being visited with css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

cssSet the background of the link being visited

When the mouse clicks on the link, set its background color to yellow.

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style type="text/css">
			a:active {
				background: yellow;
				/* background:url(img/1.jpg); */
			}
		</style>
	</head>
	<html>
		<body>
			<a href="#">链接</a>
		</body>
	</html>
Copy after login

Rendering:

How to set the background of the link being visited with css

Description:

:active selector can set the style when you click the link.

When you click a link it becomes the active link, and :active adds special styling to active links.

Tips: :link selector sets the link style of unvisited pages, :visited selector sets the style of visited page links, :hover selector is used when the mouse is hovering over it link style.

Note: In order to produce the desired effect, in the CSS definition, :active must be located after :hover! !

Recommended tutorial: "CSS Video Tutorial"

The above is the detailed content of How to set the background of the link being visited with css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template