Can CSS do this? |
Can CSS do this? |
CharlesEF |
Nov 10 2024, 02:12 PM
Post
#1
|
Programming Fanatic Group: Members Posts: 1,996 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Sorry for the crappy title, I wasn't sure how to word it. Anyway, my page layout is:
CODE <label>XXXX:</label><br> I want to prevent the label from printing on 1 page while the input is printed on another page. Can CSS do this?<input> Thanks for any input, Charles |
Christian J |
Nov 10 2024, 03:21 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,743 Joined: 10-August 06 Member No.: 7 |
Not sure what you mean, something like Page breaks?
https://www.w3.org/TR/CSS21/page.html#page-breaks |
coothead |
Nov 10 2024, 03:32 PM
Post
#3
|
Advanced Member Group: Members Posts: 234 Joined: 12-January 23 From: chertsey, a small town 25 miles south west of london, england Member No.: 28,743 |
|
pandy |
Nov 10 2024, 09:40 PM
Post
#4
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,766 Joined: 9-August 06 Member No.: 6 |
He says not print.
Give a containing element (add one if there isn't a suitable one already) an id (or class of you want to use this for more than once on a page) then make it display: none in a print style sheet. CODE @media print { .noprint { display: none } } |
CharlesEF |
Nov 19 2024, 12:44 PM
Post
#5
|
Programming Fanatic Group: Members Posts: 1,996 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Ok, let me try again. I don't want to hide anything. When I have a page loaded and hit the 'Print' button I may get a 1, 2 or 3 page print out. I want the label and input to print on the same page. Of course, the input could be a select or textarea but I still want them to print on the same page.
I had already looked at CSS page breaks but haven't gotten it to work yet, hence the question. If I need to change the HTML layout a little that's fine. I just want them printed on the same page. |
coothead |
Nov 19 2024, 03:26 PM
Post
#6
|
Advanced Member Group: Members Posts: 234 Joined: 12-January 23 From: chertsey, a small town 25 miles south west of london, england Member No.: 28,743 |
Hi there CharlesEF,
coothead |
CharlesEF |
Nov 20 2024, 11:40 AM
Post
#7
|
Programming Fanatic Group: Members Posts: 1,996 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
That CSS is what i have tried, except I didn't include the '+ br' part. Let me try it out and report back.
Thanks for the tip. |
CharlesEF |
Nov 21 2024, 05:35 PM
Post
#8
|
Programming Fanatic Group: Members Posts: 1,996 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
I'm still testing. I find that if the printer setting has 'Shrink to fit page' it appears to work. But, if I change the setting to 125% or higher then it appears to not work. Some pages have the label (field name) printed at the bottom of the page. While the input (data) is printed at the top of the next page. I also see some images partly printed at the bottom of the page while the remaining part is printed at the top of the next page.
This is what I want to avoid. If there is not enough room at the bottom of the page to print both the label and input (or select or textarea or img) then I want the whole section to print at the top of the next page. |
coothead |
Nov 21 2024, 06:24 PM
Post
#9
|
Advanced Member Group: Members Posts: 234 Joined: 12-January 23 From: chertsey, a small town 25 miles south west of london, england Member No.: 28,743 |
Hi there CharlesEF,
coothead |
Christian J |
Nov 21 2024, 07:25 PM
Post
#10
|
. Group: WDG Moderators Posts: 9,743 Joined: 10-August 06 Member No.: 7 |
I want the label and input to print on the same page. Of course, the input could be a select or textarea but I still want them to print on the same page. Could the TEXTAREA be filled with an unknown amount of user content? Without any limits to such content it might be impossible to print on a single page of paper... |
CharlesEF |
Nov 22 2024, 04:49 PM
Post
#11
|
Programming Fanatic Group: Members Posts: 1,996 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Ok, I think I figured it out. When using 'labe + br' as the CSS selector I think it didn't work because the closing label tab didn't surround the input tag. I would have had to modify many pages so I used the parent div instead. Everything appears to work correctly now. Images don't print on 2 pages anymore, at any scale. (tested up to 200%)
I don't think textareas cause any problem. In fact, any page with a textarea gets expanded to full height before printing. This way all text in the textarea is printed. I use the events onafterPrint and onbeforePrint for this. Thanks for all the input. |
Lo-Fi Version | Time is now: 4th December 2024 - 05:37 AM |