asp.net-mvc - ASP.NET MVC,CSS 样式仅适用于部分 View ,如 <style scoped>

标签 asp.net-mvc html css asp.net-mvc-5

有一个名为 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 ,如 &lt;style scoped>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28693161/

相关文章:

html - 如何用纯CSS创建文字描边和三 Angular 形?

javascript - Fadein 和 Fadeout 阻止 jquery 函数正常工作

javascript - 带有光标 Javascript 的自动打字机

asp.net - IIS 版本 10.0 - 请求被困在状态为 RequestAcquireState 的工作进程中 - 模块是 session

asp.net-mvc - 后台任务/作业/进程,在 asp.net MVC 3 中

javascript - 通过Id访问DOM元素

jquery - Team Treehouse 导航栏动画

java - 是否有类似于 Razor 的模板语言用于 Java Spring Web 应用程序?

asp.net-mvc - 如何在 MVC 5 Razor 中设置日期格式

html - 使用 css 选择选择菜单的一个选项后,如何更改文本颜色?