我设置了一些 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/