-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inverse of 'no-print' #20
Comments
Good idea but the problem is that the stylesheet is loaded with the <link rel="stylesheet" href="..." media="print"> A solution would be to load the stylesheet anyway, without any media (for all of them) but then you will have the print style applied everywhere. An other solution would be to add this css for all media .print-only {
display: none;
}
@media only print {
.print-only {
display: initial;
}
} What do you think about it ? |
In hindsight I could have worded my request better. What you propose works correct for content that's only for print. However, I was searching for something that lets me add this to a legacy system without sprinkling .no-print classes everywhere. So i'm looking for something that lets me print only one part of the page. For example, print only the part with 'print!' from a page that look like this:
|
Ok yes, I see. So it would be more something like // We hide all elements
* {
display: none;
}
// Except .print-only
.print-only {
display: initial;
} The problem is that I can't really add |
Children of elements that are not displayed could not be made visible anymore... Maybe it is too complicated to solve in a library... |
The problem with the Given the case that was presented here, and the problems I identified, I think the closest you could get (assuming we're using only CSS): * {
display: none !important;
}
/* If you used something like display: grid for body, that's gone now. */
html,
body {
display: revert !important;
}
/* Get all of our display values as close as possible to what we want */
.print-only,
.print-only * {
display: revert !important;
}
/* Set the more fancy display values to what they were before */
.print-only.l-flex,
.print-only .l-flex {
display: flex !important;
}
.print-only.l-grid,
.print-only .l-grid {
display: grid !important;
}
/* ... */
Unfortunately though: Maybe if you had a JS file that allowed you to traverse the DOM and find the computed display values before the print stylesheet is applied, and then creates a dynamic stylesheet that would reset those values when a |
Thanks, but I made a big ugly selector hiding everything i didn't want. Its not the best solution but fine as long as we're using the legacy stuff |
To make it easier for implementing in a legacy system a 'print-only' class would be super-useful.
The text was updated successfully, but these errors were encountered: