有一个名为 scoped 的新 html 属性但它是now implemented only in firefox .该属性允许您仅为父元素声明内部样式。
我想知道这是否有可能在 ASP.NET MVC 局部 View 中模拟这种行为而不创建一些包装器 <div class="wrapperOverPartial">
假设我们有一个名为 Infoes
的 View
//some specific css here or css imported from file
<h2>Infoes</h2>
<address>
@Html.Partial("SomeSpecificInfo")
</address>
和局部 View SomeSpecificInfo
<style>
//some internal styles defined here
</style>
<h2>Some Specific Info</h2>
我希望这些样式仅适用于 SomeSpecificInfo
内部使用 scoped
时的方式相同,这可能吗?
最佳答案
在局部 View 中定义内联的 css。
在 SomeSpecificInfo
<style>
//Your custom class
</style>
The rest of your partial view.
这会将类的范围仅限于 SomeSpecificInfo
页面。
关于asp.net-mvc - ASP.NET MVC,CSS 样式仅适用于部分 View ,如 <style scoped>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28693161/