我想为Asp.Net项目设置透明的菜单背景。我使用下一个代码:
<%@ Master Language="C#" CodeBehind="Site.master.cs" Inherits="Solution.Site" %>
<!DOCTYPE html>
<html lang="ru" style="height: 100%; margin: 0; padding: 0; position:relative">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta charset="utf-8" />
<title>My title</title>
<link href="~/Site.css" rel="stylesheet" type="text/css" />
<link href="Styles/ByClasses.css" rel="stylesheet" type="text/css" />
<link href="Styles/ByElements.css" rel="stylesheet" type="text/css" />
</head>
<body class="template">
<form id="form1" runat="server">
<div class="logoDiv">
<asp:Image runat="server"
AlternateText="MyCompanyLogo"
ImageAlign="Top"
Height ="100%"
ImageUrl="DynamicData/Content/Images/MyCompanyLogo.png"/>
</div>
<div class="menuDiv">
<asp:Menu runat="server" StaticDisplayLevels="3" CssClass="menu">
<Items>
<asp:MenuItem Text="File" Value="File">
<asp:MenuItem Text="New" Value="New"></asp:MenuItem>
<asp:MenuItem Text="Open" Value="Open"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="Edit" Value="Edit">
<asp:MenuItem Text="Copy" Value="Copy"></asp:MenuItem>
<asp:MenuItem Text="Paste" Value="Paste"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="View" Value="View">
<asp:MenuItem Text="Normal" Value="Normal"></asp:MenuItem>
<asp:MenuItem Text="Preview" Value="Preview"></asp:MenuItem>
</asp:MenuItem>
</Items>
</asp:Menu>
</div>
<div class="mainContentDiv">
<asp:ContentPlaceHolder id="master_contentPlaceHolder" runat="server"/>
</div>
<div class="footerDiv">Copyright MyCompany</div>
</form>
</body>
</html>
next&#34; ByClasses.Css:&#34;
.logoDiv {
background:White;
width:100%;
height:10%;
}
.menuDiv {
background:Yellow;
float:left;
width:15%;
height:88%;
}
.mainContentDiv {
background:Green;
float:left;
width:85%;
height:88%;
}
.footerDiv {
background:White;
clear:both;
width:100%;
height:2%;
}
.menu{
background-color:transparent;
width:100%;
float: left;
clear: both;
font-family: Arial, Helvetica, sans-serif;
}
和&#34; ByElements.Css&#34;:
body {
height:100%;
width:100%;
margin:0;
padding:0;
position:relative;
}
form {
width:100%;
height:100%
}
但我的菜单有白色背景,我不明白为什么。任何人都可以告诉我,错误是什么以及如何为菜单设置透明背景?
答案 0 :(得分:1)
我不明白你到底需要什么 如果您需要首先删除菜单背景颜色,则需要删除.menuDiv背景
.menuDiv{background:none}