A new CSS image replacement technique (background display and text moving off screen) to say goodbye to 9999px

A new CSS image replacement technique (background display and text moving off screen) to say goodbye to 9999px
-9999 px image replacement technology has been popular for the best part of a decade. To replace a text element with an image, you can use the following code:

Copy code
The code is as follows:

<h1>This Text is Replaced</h1>
<style>
h1
{
background: url("myimage") 0 0 no-repeat;
text-indent: -9999px;
}
</style>

The element's background is displayed and its text is moved offscreen so that it doesn't get in the way. Simple and effective. It's often used to display graphic captions - this is rarely necessary now that we have webfonts, but you'll still find it useful when using it on the web.
Until now.
A new technology has been discovered:

Copy code
The code is as follows:

{
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}

Code indents the text beyond the width of its container, but it does not wrap and overflow is hidden.
While this is a little longer and harder to remember, it can improve performance because the browser is no longer drawing a 9999px box behind the scenes. It will also prevent the weird left expanded outlines you'll see around links by using hidden text.

<<:  Specific use of Mysql prepare preprocessing

>>:  Some ways to solve the problem of Jenkins integrated docker plugin

Recommend

VMware ESXi 5.5 deployment and configuration diagram process

Table of contents 1. Installation requirements 2....

Drop-down menu and sliding menu design examples

I found a lot of websites that use drop-down or sl...

Web Theory: Don't make me think Reading Notes

Chapter 1 <br />The most important principl...

How to set and get the number of Mysql connections

Get the number of connections --- Get the maximum...

About Nginx gzip configuration

The principle of nginx to achieve resource compre...

Split and merge tables in HTML (colspan, rowspan)

The code demonstrates horizontal merging: <!DO...

64-bit CentOs7 source code installation mysql-5.6.35 process sharing

First install the dependent packages to avoid pro...

A brief discussion on ifnull() function similar to nvl() function in MySQL

IFNULL(expr1,expr2) If expr1 is not NULL, IFNULL(...

How to access MySql through IP address

1. Log in to mysql: mysql -u root -h 127.0.0.1 -p...

Detailed analysis of javascript data proxy and events

Table of contents Data Brokers and Events Review ...

The latest version of MySQL5.7.19 decompression version installation guide

MySQL version: MySQL Community Edition (GPL) ----...

How to install ELK in Docker and implement JSON format log analysis

What is ELK? ELK is a complete set of log collect...

Summary of three ways to implement ranking in MySQL without using order by

Assuming business: View the salary information of...

Detailed steps to build an NFS file sharing server in Linux

Linux builds NFS server In order to achieve data ...