I have the following:
@if (Model.PageMeta.Sidebar == PageMetaSidebar.Small) { Html.RenderPartial("_SmallSidebar"); }
and in my include file:
<style "text/css"> #sbr { width: 193px; } #lft { left: 205px; top: 85px; right: 5px; bottom: 30px; } #top { left: 215px; top: 85px; right: 15px; } #btm { left: 215px; right: 15px; bottom: 30px; } #mdl { left: 215px; top: 85px; right: 15px; bottom: 30px; } @media print { div#lft {left:10px; right: 10px; top: 0px;} div#top {left:20px; right: 20px; top: 0px;} div#btm {left:20px; right: 20px; } div#mdl {left:20px; right: 20px; top: 0px;} } } </style>
However this gives me a compile type error:
_SmallSidebar.cshtml(7): error CS0103: The name 'media' does not exist in the current context
Does anyone out there know how I could fix this so it accepts that @media is not something that needs to be evaluated?
All you have to do is to place a style sheet in the Pages folder alongside the page that it is intended to affect. You just need to follow a specific naming convention, which is the Razor page file name with . css on the end. The bundled file itself is placed in the wwwroot folder when the application is published.
The @media CSS at-rule can be used to apply part of a style sheet based on the result of one or more media queries. With it, you specify a media query and a block of CSS to apply to the document if and only if the media query matches the device on which the content is being used.
The important purpose of @media directive is to set style rules for various kinds of media types and could be nested inside the SASS selector.
CSS Syntax only: The only keyword prevents older browsers that do not support media queries with media features from applying the specified styles. It has no effect on modern browsers. and: The and keyword combines a media feature with a media type or other media features. They are all optional.
You can use @@
which razor ignores and prints one @
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With