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

How to create, start, and stop a Docker container

1. A container is an independently running applic...

Mysql: The user specified as a definer ('xxx@'%') does not exist solution

During the project optimization today, MySQL had ...

MySQL deduplication methods

MySQL deduplication methods 【Beginner】There are v...

An article to solve the echarts map carousel highlight

Table of contents Preface toDoList just do it Pre...

Some tips for using less in Vue projects

Table of contents Preface 1. Style penetration 1....

WeChat Mini Program User Authorization Best Practices Guide

Preface When developing WeChat applets, you often...

Mysql master/slave database synchronization configuration and common errors

As the number of visits increases, for some time-...

Best Practices Guide for MySQL Partitioned Tables

Preface: Partitioning is a table design pattern. ...

Detailed tutorial on installing PHP and Nginx on Centos7

As the application of centos on the server side b...

HTML dl, dt, dd tags to create a table vs. Table creation table

Not only does it reduce the cost of website develo...

Centos7 installation of Nginx integrated Lua sample code

Preface The computer I use is a Mac, and the oper...

Zabbix WEB monitoring implementation process diagram

Take zabbix's own WEB interface as an example...