


Basic knowledge of mini programs and detailed explanation of css style media tags
微信小程序 基础知识css样式media标签
前言:
微信小程序中我遇到了一个对我来说是新的东西,但是对于前端开发来说不算是新知识,html页面中的media标签,在此记录下来以备不时之需
在css中我们使用media标签来区分调用哪个css样式,比如使用media=”print”来表示当执行打印文档时,使用print.css样式。这样使得文档更有得于打印,如将页面宽度增宽、或屏蔽掉一些不需要打印的内容。
<link href="styles/main.css" rel="external nofollow" rel="stylesheet" type="text/css" media="screen" /> <link href="styles/print.css" rel="external nofollow" rel="stylesheet" type="text/css" media="print" /> <link href="main.css" rel="external nofollow" rel="stylesheet" type="text/css" media="all'/>
下边是media标签的10个值,可见常用的并不多。当没有media标签时,默认为media=”all”。
all– 用于所有设备类型
aural– 用于语音和音乐合成器
braille– 用于触觉反馈设备
embossed– 用于凸点字符(盲文)印刷设备
handheld– 用于小型或手提设备
print– 用于打印机
projection– 用于投影图像,如幻灯片
screen– 用于计算机显示器
tty– 用于使用固定间距字符格的设备。如电传打字机和终端
tv– 用于电视类设备
在上边引用css样式时,我们引用了两次。我们完全可以引用一个css样式来达到我们的目的,这样也可以提高css样式加载速度,
实现代码如下:
CSS代码
@media all { body{ font:12px; width:100%;} } @media print { body{ font:14px; width:595px;} /* 用于打印时将宽度设置为595px(A4) */ }
以上media标签是css中的标准语法,所有浏览器都支持media标签,但下面的写法出IE6\7\8 以为的浏览器都支持
CSS代码
@media all and (min-width: 1001px) { #sidebar ul li a:after { content: " (" attr(data-email) ")"; font-size: 11px; font-style: italic; color: #666; } } @media all and (max-width: 1000px) and (min-width: 700px) { #sidebar ul li a:before { content: "Email: "; font-style: italic; color: #666; } } @media all and (max-width: 699px) and (min-width: 520px), (min-width: 1151px) { #sidebar ul li a { padding-left: 21px; background: url(../images/email.png) left center no-repeat; } }
也有人这么搞
@media screen and (-webkit-min-device-pixel-ratio: 1.0), screen and (min--moz-device-pixel-ratio: 1.0), screen and (min-device-pixel-ratio: 1.0), screen and (min-resolution: 1.0dppx) { .icon-del { background-image: url(../../resources/images/ui_3@2x.png); background-size: 274px 228px; display: block; } }
The above is the detailed content of Basic knowledge of mini programs and detailed explanation of css style media tags. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Some users encountered the problem that checking media cannot be started when starting a Lenovo laptop, which is confusing. So how to solve the problem of checking media not starting on Lenovo computers? This tutorial will bring you the reasons and solutions for checking media failing to start on Lenovo laptops. Causes: 1. Hard drive damage: If the Lenovo notebook has hard drive damage or failure, it will cause the notebook to display checking media and not boot. The operating system is damaged: If the operating system of a Lenovo notebook is damaged, it will cause the notebook to display checking media and be unable to boot. 2. Restart the computer, press F12 to enter the BIOS, and select the "Startup" item.

MySQL is an open source relational database management system that is widely used in web application development and data storage. Learning MySQL's SQL language is very necessary for data managers and developers. SQL language is the core part of MySQL, so before learning MySQL, you need to have a full understanding of SQL language. This article aims to explain the basic knowledge of SQL statements to you in detail, so that you can understand SQL statements step by step. SQL is the abbreviation of Structured Query Language, which is used in relational data

Starting from Scratch: Introduction to the Basics of Learning Go Language Go language, also known as Golang, is an open source programming language developed by Google. It was released in 2009 and quickly became a popular language, especially in fields such as web development, distributed systems, and cloud computing. The Go language is famous for its simplicity, efficiency, and strong concurrency. Basic syntax 1. Variables and constants In the Go language, variables and constants are typed. Variables can store data, while constants cannot be changed. The declaration format of variables is: v

Yii is a popular object-oriented PHP framework. Its full name is "YesItIs", which means "Yes, it is like this". It is designed to be efficient, fast, secure and easy to use, so it is widely used in the development of large-scale web applications. In this article, we will introduce some basic knowledge of Yii framework to help novices better understand this framework. MVC architecture Yii framework adopts a design pattern based on MVC (Model-View-Controller), which

What basic knowledge do you need to learn canvas? With the development of modern web technology, using the <canvas> tag in HTML5 for drawing has become a common way. Canvas is an HTML element used to draw graphics, animations and other images, which can be manipulated and controlled using JavaScript. If you want to learn canvas and master its basic knowledge, the following will introduce it to you in detail. HTML and CSS basics: before learning canvas

Quick Start Go Language Programming: Basic Knowledge and Practice Guide Go language, as an emerging programming language, is favored by developers for its simplicity, efficiency and concurrency. Whether you are a beginner or a developer with some programming experience, this article will take you quickly into Go programming and provide some practical guidelines and specific code examples. 1. Install the Go language environment. To start programming in the Go language, you first need to install the Go language environment on your computer. You can download it from Go official website (https://golang

"In-depth Discussion on the Basics of Go Language Programming: Analysis of Specific Code Examples" As a fast and efficient programming language, Go language is increasingly favored by programmers and developers. In the process of learning and mastering the Go language, it is crucial to have a deep understanding of its basics. This article will conduct an in-depth discussion on variables, data types, process control, functions, etc., and combine it with specific code examples to help readers better understand and master the basic knowledge of the Go language. Variables and data types In Go language, the declaration and initialization of variables are very

Learn the basics of Go language input functions from scratch. Go language is a statically typed, compiled, and concurrent programming language developed by Google. It has concise syntax, efficient concurrency model and excellent performance, so it is favored by developers. In the process of learning Go language, understanding input functions is one of the most important basic knowledge. This article will start from scratch, introduce the basic knowledge of Go language input functions, and give specific code examples. 1.fmt package In the Go language, the fmt package is used to format input and
