asp.net - 母版页和CSS

标签 asp.net css master-pages

我设置了一些 css 规则和 html 标签,在设计 View 中看起来很理想。但是当母版页的子表单加载页面时,它看起来会有所不同。子 css 规则能否控制父 css 规则的属性。

style type="text/css">
#container{position:relative;}
img#border{position:absolute; 

}
#placeH{position:absolute; left:344px;
    top: 325px;
    height: 168px;
    width: 708px;
    bottom:287px;
}

<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>

<div align="center" id="container">
    <asp:Image ID="Header" runat="server" ImageUrl="~/header.png" Width="1196px" 
        Height="280px" />


  </div>
      <div id="border">

            <asp:Image ID="Image1" runat="server" ImageUrl="~/border.png"/>// the border

我尝试在此处设置的内容在母版页设计 View 中看起来很好..但在 child 身上 设计 View ,它出现在页面的左下方

              </div>

                  <div id="placeH">
                         <form id="form1" runat="server">
                        <asp:ContentPlaceHolder id="ContentPlaceHolder2" runat="server">

                           </asp:ContentPlaceHolder>
                    </form>

                  </div>
           </body>

最佳答案

我在这里唯一能看到的就是那个。您有一些 CSS 可能不会像您预期的那样运行。

img#border{position:absolute;}

这将适用于 <img/>带有 id="border"的标签。在上面的 HTML 中,您在 div 中有一个带有 id="border"的 img。您的 CSS 应该看起来像这样。

div#border > img { postition:absolute; }  if you want it applied to the image only.

#border { position:absolute; } if you want it applied to the whole div.

实际上很难在上面的 HTML 中看到这些片段。如果以上没有解决问题,请将整个内容粘贴给我。

关于asp.net - 母版页和CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5848853/

相关文章:

c# - 如何从 ASP.NET 应用程序连接到服务器端 USB (HID) 设备?

html - flex 盒元素内固定元素的宽度

css - 有没有办法在 Visual Studio 中查看 sass 文件的行号?

asp.net - ASP.NET 母版页和内容页中的表单元素

asp.net - 对嵌套母版页使用继承

c# - 使用保存到内存流的图像导出文件

c# - .NET CSV uploader 允许空值

c# - ASP.NET MVC : redirect to another controller with POST Action

html - 标签内的div是否有任何修复

asp.net - 防止在每次回帖或登录后页面加载时加载母版页内容