1

I'm trying to prevent pages from breaking while printing the contents of a div.

Important to say that i'm using tailwind.

I have tried using: break-after-page, break-after-auto , break-before-page, break-before-auto break-page-inside avoid

on the table,thead and on the div where i'm using grid.

yet it doesnt help the issue i'm facing pictured here

this is my code :

<div className="pt-10 text-3xl">{t('quality_indices')}</div>
        <div className="relative rounded-lg border">
          <table className="w-full text-left text-sm text-gray-100 dark:text-gray-600">
            <thead className="table-row-group bg-gray-100 text-right text-xs uppercase text-gray-700">
              <tr className="p-14">
                <th scope="col" className=" rounded-tr-lg px-2 py-2">
                  {t('issue_examined')}
             
                </th>
                <th scope="col" className="border-r-2 px-2 py-2">
                  {t('requirement')}

             
                </th>
                <th scope="col" className="border-r-2 px-2 py-2">
                  {t('planning')}
                  
                </th>
                <th scope="col" className="border-r-2 px-2 py-2">
                  {t('test')}
               
                </th>
                <th scope="col" className="border-r-2 px-2 py-2">
                  {t('explanation')}
         
                </th>
                <th scope="col" className="border-r-2 px-2 py-2">
                  {t('notes')}
             
                </th>
                <th scope="col" className="rounded-tl-lg border-r-2 px-2 py-2">
                  {t('deviations')}
                  {/* סטיות */}
                </th>
              </tr>
            </thead>
            <tbody>
              {data.qualityIndices.map(element => (
                <>
                  <tr className="   border-b border-t bg-white text-right text-black ">
                    <th
                      scope="row"
                      className="whitespace-nowrap px-4 py-1 font-medium"
                    >
                      {element.issueExamined}
                    </th>
                    <td className="border-r-2 px-4 py-3">
                      {element.requirementCharachterization}
                    </td>
                    <td className="border-r-2 px-4 py-3">
                      {element.planningAndExecution}
                    </td>
                    <td className="border-r-2 px-4 py-3">
                      {element.matchTests}
                    </td>
                    <td className="border-r-2 px-4 py-3">
                      {element.explanation}
                    </td>
                    <td className="border-r-2 px-4 py-3">
                      {element.explanation}
                    </td>
                    <td className="border-r-2 px-4 py-3">
                      {element.deviations}
                    </td>
                  </tr>
                  <tr>
                    <td colspan="10" className="text-black">
                      <div className="grid grid-cols-3 gap-2 pt-3">
                        {element.picturesAndNotes.map((picture, index) => (
                          <div className="  rounded-3xl border bg-white px-2 pt-2 pb-3 text-right">
                            <p className="text-lg">
                              {' '}
                              <span className="text-orange">#{index + 1}</span>:{' '}
                              <span className="font-bold text-black">
                                {picture.uploader}
                              </span>
                            </p>
                            <p>
                              {picture.hour} - {picture.date}
                            </p>
                            <div>
                              <img
                                className="h-[15vh] w-screen  object-fill pt-10 lg:h-[20vh]"
                                src={picture.url}
                              />
                            </div>
                            <p>{picture.title}</p>
                          </div>
                        ))}
                      </div>
                    </td>
                  </tr>
                </>
              ))}
            </tbody>
          </table>
        </div>
lulav
  • 33
  • 1
  • 5
  • Does this answer your question? [Print styles: How to ensure image doesn't span a page break](https://stackoverflow.com/questions/2649169/print-styles-how-to-ensure-image-doesnt-span-a-page-break) – Sven Jul 11 '22 at 12:59
  • i still have my pictures halved by the page break. tried both break-inside-avoid and break-inside-auto – lulav Jul 11 '22 at 13:30
  • It seems like your issue is with Tailwind, not React, if you'd like help then you should provide a reproducible example without your framework code in the way. You can do this by copying the rendered HTML in your browser's devTools. – JHeth Jul 12 '22 at 05:13

0 Answers0