我一直在网上寻找解决方案.我想要一件事.当使用@media print {...}时我想要隐藏身体内的所有元素但只有一个.怎么做?我有class ="print",我不想隐藏,如何隐藏所有没有那个类?
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
@media print {
:not(.print) {
display: none
}
}
</style>
</head>
<body>
<div class="print">
<p>neki lijepi tekst</p>
<p> test</p>
</div>
<div id="test"> ovo se ne vidi naa printu </div>
<div id="tesft"> ovo se nedsfdf vidi naa printu </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在没有print类的情况下隐藏身体的每个子元素
body > * { display: none }
.print { display: block }
Run Code Online (Sandbox Code Playgroud)
一旦没有文本节点直接在bodytis应该工作.
| 归档时间: |
|
| 查看次数: |
4129 次 |
| 最近记录: |