-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_media_query.html
76 lines (68 loc) · 2.24 KB
/
simple_media_query.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!doctype html>
<html>
<head>
<meta charset="utf-8" content="width=device-width, height=device-height">
<title>Simple Print Media Query</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<style>
.box {
height: 50vh;
width: 50vw;
}
@media screen {
.background{
background-color: rgb(0, 0, 255);
color-adjust: exact;
}
.only-print {
display: none !important;
}
}
@media print {
.background{
background-color: rgb(255, 113, 57);
color-adjust: exact;
}
.no-print, .no-print * {
display: none !important;
}
}
</style>
<div class="container">
<h1 class="pt-4 ">Printing CSS Included</h1>
<div class="alert alert-primary no-print" role="alert">
Just a banner that will hide when printing due to CSS media queries
</div>
<h2 class="no-print">Print</h2>
<div class="no-print row" >
<div class="col-6 no-print">
<button class="btn btn-primary btn-lg" onclick="window.print();">Print Page</button>
</div>
</div>
<h2>Info</h2>
<p>
This is a simple print test. There are some CSS media queries that change the way the website will appear when printing versus on the screen!
</p>
<p>This is the ideal way to print!</p>
<p class="only-print">
Notice a lot of things changed in the print layout to optimize for printing. The banner was removed, as well as the print button, and some thins appeared.
</p>
<h2 class="only-print">List Only Appears in Print</h2>
<p class="only-print">The list is set to only appear during printing.</p>
<ul class="only-print">
<li>Print List 1</li>
<li>Print List 2</li>
<li>Print List 3</li>
</ul>
<h2>Print CSS Media Query Box</h2>
<p>
The box below has a <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/Printing#using_media_queries_to_improve_layout">print css media</a> query.
</p>
<p>
It will appear blue on screen and orange in print.
</p>
<div id="content" class="box background">
</div>
</div>
</html>