Foundation 5 and page printing

后端 未结 4 1833
花落未央
花落未央 2021-02-06 08:25

I\'m using Zurb Foundation. I\'m trying to print a page exactly as it looks in large screen but everything get stacked (and floated wrong).

I succeded in having the grid

4条回答
  •  感动是毒
    2021-02-06 08:36

    Do I need to recompile foundation with sass?

    Well, yes. You need to create a custom sass file and put the print rules inside that. Then recompile the file with Sass compiler.

    Inside the scss/ folder you have these two normalize.scss and foundation.scss files. Create a new file named app.scss and import the normalize and foundation as follows:

    // Import the normalize.scss
    @import "normalize";
    
    // Import the foundation.scss
    @import "foundation";
    
    // Your own SCSS here...
    

    And then put the below code snippet at the end of app.scss file as suggested by Rafi Benkual:

    For example you could force the large grid to be print friendly by adding in the following code to your project:

    // This would make the large grid function like a print grid
    @media print {
      @for $i from 1 through $total-columns {
        .large-#{$i} {
          width: gridCalc($i, $total-columns);
        }
      }
    }
    

    Note: This may or may not work. I didn't try this myself. However it's deemed helpful at Foundation Forum.

    The $total-columns variable is defined in scss/foundation/components/_grid.scss file, which you can override that (as the other settings) by editing scss/foundation/_settings.scss. Hence you need to import @import "foundation/settings"; before the foundation file.

    Finally, compile the app.scss file by: sass --watch app.scss:app.css

提交回复
热议问题