php help
- Started
- Last post
- 8 Responses
- sseo
I'm making a print stylesheet for a website and I'm finding display:none isn't enough. Anyone know if I use PHP to remove images from a page if the print.css stylesheet is called?
The problem is that I'm using this:
.entry a:link:after, .entry a:visited:after {
content: " (" attr(href) ") ";
font-size: 90%;
}
to spell out the link address, but even if an element is hidden through the display property, this rule expose the link.
- sseo0
ugh... "if I *can use PHP" and "this rule *exposes the link"
mornings.
- stewdio0
I agree with @seeessess. Don't try using PHP to cover up a bug in your CSS. Instead, track down the bug in CSS and fix it. Haven't had my second cup either though.
- thanks but really, there is no bug. I guess it's the way child elements inherit parent properties that is the 'problem' heresseo
- tFour0
how about resetting everything with
* { display: none; }
and re-styling the parts you want for print?
- sseo0
well, it's not a bug. I'm using a:link:after {content: " (" attr(href) ") ";} to reveal the actual hyperlink url after every link on printed versions.
img {display:none} will hide the image, but a:link:after {content: " (" attr(href) ") ";} will show the link for each image, even if the image itself is hidden (since the images all have links to larger versions). As the images aren't important, I don't mind removing them from the print version altogether.
- seeessess0
can you not give that a:link:after a class, and hide a.yourclass {display:none} in the print?
- sseo0
So, I've been trying some of the suggestions, and the closest I've come to is being more specific in what I select to have the a:link:after property. By doing this:
.entry > p a:link:after, .entry > p a:visited:after {
content: " (" attr(href) ") ";
font-size: 90%;
}I was able to select just elements in the div called entry that are surrounded by p tags. This solves the problem for most images, but not all, as there are some images that get automatically wrapped in p tags. Now I just need to figure out how to strip those out...
Anyway, thanks for the suggestions, this was not fun early in the day.