How to customize more beautiful link prompt effect with CSS

How to customize more beautiful link prompt effect with CSS
Suggestion: Handwriting code as much as possible can effectively improve learning efficiency and depth.
By default, you can use the title attribute of the <a> tag to achieve a link prompt effect. For example

Copy code
The code is as follows:

View Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>Ant Tribe</title>
</head>
<body>
<a href="http://www.softwhy.com" title="Ant Tribe">Ant Tribe</a>
</body>
</html>

Although the above code can achieve the link prompt effect, it often cannot meet the actual needs. You may need to customize the link prompt effect that is more beautiful or matches the page. The code example is as follows

Copy code
The code is as follows:

View Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="http://www.softwhy.com/" />
<head>
<title>Ant Tribe</title>
<style type="text/css">
ul
{
list-style:none;
font-size:14px;
}
li
{
width:100px;
height:30px;
line-height:30px;
float:left;
text-align:center;
position:relative;
border:1px solid red;
}
span
{
display:none;
}
a:link,a:visited
{
text-decoration:none;
}
a:hover .tishi
{
display:block;
width:100px;
height:30px;
background-color:#6C9;
line-height:30px;
text-align:center;
position:absolute;
left:80px;
top:40px;
color:#FFFFFF;
}
</style>
</head>
<body>
<ul>
<li>
<a href="#" class="mylink">DIV+CSS<span class="tishi">DIV+CSS</span></a>
</li>
<li>
<a href="#" class="mylink">jQuery<span class="tishi">jQuery</span></a>
</li>
<li>
<a href="#" class="mylink">JS<span class="tishi">JS</span></a>
</li>
<li>
<a href="#" class="mylink">HTML<span class="tishi">HTML</span></a>
</li>
<div style="clear:both"></div>
</ul>
</body>
</html>

The above code successfully achieves the effect we want. The main method is to use the hyperlink pseudo-class to display the span element

<<:  Implement a simple search engine based on MySQL

>>:  idea uses docker plug-in to achieve one-click automated deployment

Recommend

MySQL 5.7.17 and workbench installation and configuration graphic tutorial

This article shares the installation and configur...

Problems and experiences encountered in web development

<br />The following are the problems I encou...

Analyze several common solutions to MySQL exceptions

Table of contents Preface 1. The database name or...

Example code for drawing double arrows in CSS common styles

1. Multiple calls to single arrow Once a single a...

Four data type judgment methods in JS

Table of contents 1. typeof 2. instanceof 3. Cons...

Steps for Docker to build a private warehouse Harbor

Harbor Harbor is an open source solution for buil...

How to keep running after exiting Docker container

Phenomenon: Run an image, for example, ubuntu14.0...

Comparison of the advantages of vue3 and vue2

Table of contents Advantage 1: Optimization of di...

Flex layout makes adaptive pages (syntax and examples)

Introduction to Flex Layout Flex in English means...

A practical record of troubleshooting a surge in Redis connections in Docker

On Saturday, the redis server on the production s...

Example of how to enable Brotli compression algorithm for Nginx

Brotli is a new data format that can provide a co...

Learning Vue instructions

Table of contents 1. v-text (v-instruction name =...