2013-06-29 100 views
0

我有一個CSS背景的母版頁,也使用另一個div來給我想要放在頁面上的內容框。但是,當我將內容div縮放爲1000px時,背景div看起來並沒有看到我已經將內容div擴展到當前高度以上。任何人有任何想法呢?我認爲這與母版頁內容控制有關,但我不確定。CSS背景顏色不縮放ASP.NET

我在這裏的一些東西一直是我玩它。例如,我將內容框硬編碼到100%的高度,但它不會有,因爲我希望內容框根據其內容進行擴展。但硬編碼的高度使我能夠顯示背景如何與內容無關的事實。

下面是代碼: CSS:

body 
{ 
border: 0px none; 
margin: 0px; 
padding: 0px; 
} 

.Button 
{ 
font-family: Arial, Helvetica, sans-serif; 
font-size: large; 
font-weight: bold; 
color:White; 
border-style: solid; 
border-width: thin; 
border-color: Black; 
display: block; 
width: 100px; 
height: 25px; 
margin: 0 auto; 
-webkit-border-radius: 10px; 
-moz-border-radius: 10px; 
border-radius: 10px; 
clear: both; 
background: rgb(208,228,247); /* Old browsers */ 
background: -moz-linear-gradient(45deg, rgba(208,228,247,1) 0%, rgba(115,177,231,1) 

24%, rgba(10,119,213,1) 50%, rgba(83,159,225,1) 79%, rgba(135,188,234,1) 100%); /* FF3.6+ */ 
    background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,rgba(208,228,247,1)), color-stop(24%,rgba(115,177,231,1)), color-stop(50%,rgba(10,119,213,1)), color-stop(79%,rgba(83,159,225,1)), color-stop(100%,rgba(135,188,234,1))); /* Chrome,Safari4+ */ 
    background: -webkit-linear-gradient(45deg, rgba(208,228,247,1) 0%,rgba(115,177,231,1) 24%,rgba(10,119,213,1) 50%,rgba(83,159,225,1) 79%,rgba(135,188,234,1) 100%); /* Chrome10+,Safari5.1+ */ 
    background: -o-linear-gradient(45deg, rgba(208,228,247,1) 0%,rgba(115,177,231,1) 24%,rgba(10,119,213,1) 50%,rgba(83,159,225,1) 79%,rgba(135,188,234,1) 100%); /* Opera 11.10+ */ 
    background: -ms-linear-gradient(45deg, rgba(208,228,247,1) 0%,rgba(115,177,231,1) 24%,rgba(10,119,213,1) 50%,rgba(83,159,225,1) 79%,rgba(135,188,234,1) 100%); /* IE10+ */ 
    background: linear-gradient(45deg, rgba(208,228,247,1) 0%,rgba(115,177,231,1) 24%,rgba(10,119,213,1) 50%,rgba(83,159,225,1) 79%,rgba(135,188,234,1) 100%); /* W3C */ 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#d0e4f7', endColorstr='#87bcea',GradientType=1); /* IE6-9 fallback on horizontal gradient */ 

} 

.Button:hover 
{ 
    background: rgb(247,208,228); /* Old browsers */ 
    background: -moz-linear-gradient(45deg, rgba(135,188,234,1) 0%, rgba(208,228,247,1) 24%, rgba(115,177,231,1) 50%, rgba(10,119,213,1) 79%, rgba(83,159,225,1) 100%); /* FF3.6+ */ 
    background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,rgba(135,188,234,1)), color-stop(24%,rgba(208,228,247,1)), color-stop(50%,rgba(115,177,231,1)), color-stop(79%,rgba(10,119,213,1)), color-stop(100%,rgba(83,159,225,1))); /* Chrome,Safari4+ */ 
    background: -webkit-linear-gradient(45deg, rgba(135,188,234,1) 0%,rgba(208,228,247,1) 24%,rgba(115,177,231,1) 50%,rgba(10,119,213,1) 79%,rgba(83,159,225,1) 100%); /* Chrome10+,Safari5.1+ */ 
    background: -o-linear-gradient(45deg, rgba(135,188,234,1) 0%,rgba(208,228,247,1) 24%,rgba(115,177,231,1) 50%,rgba(10,119,213,1) 79%,rgba(83,159,225,1) 100%); /* Opera 11.10+ */ 
    background: -ms-linear-gradient(45deg, rgba(135,188,234,1) 0%,rgba(208,228,247,1) 24%,rgba(115,177,231,1) 50%,rgba(10,119,213,1) 79%,rgba(83,159,225,1) 100%); /* IE10+ */ 
    background: linear-gradient(45deg, rgba(135,188,234,1) 0%,rgba(208,228,247,1) 24%,rgba(115,177,231,1) 50%,rgba(10,119,213,1) 79%,rgba(83,159,225,1) 100%); /* W3C */ 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#87bcea', endColorstr='#d0e4f7',GradientType=1); /* IE6-9 fallback on horizontal gradient */ 
} 
.Button:active 
{ 
    position: relative; 
    top: 1px; 
} 


/*Login Page */ 
#LoginBox 
{ 

    position: absolute; 
    min-height: 1px; 
    height: 300px; 
    width: 300px; 
    top: 50%; 
    left: 50%; 
    -webkit-border-radius: 25px; 
    -moz-border-radius: 25px; 
    border: 1px solid; 
    text-align:center; 
    border-radius: 25px; 
    margin:-150px 0 0 -150px; 
    background: #88bfe8; /* Old browsers */ 
    background: -moz-linear-gradient(top, #88bfe8 0%, #70b0e0 100%); /* FF3.6+ */ 
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#88bfe8), color-stop(100%,#70b0e0)); /* Chrome,Safari4+ */ 
    background: -webkit-linear-gradient(top, #88bfe8 0%,#70b0e0 100%); /* Chrome10+,Safari5.1+ */ 
    background: -o-linear-gradient(top, #88bfe8 0%,#70b0e0 100%); /* Opera 11.10+ */ 
    background: -ms-linear-gradient(top, #88bfe8 0%,#70b0e0 100%); /* IE10+ */ 
    background: linear-gradient(to bottom, #88bfe8 0%,#70b0e0 100%); /* W3C */ 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#88bfe8', endColorstr='#70b0e0',GradientType=0); /* IE6-9 */ 

} 

.LoginControls 
{ 
    width: 200px; 
    height:100px; 
    margin:-50px 0 0 -100px; 
    top: 50%; 
    left:50%; 
    position:absolute; 
} 

.WelcomeLabel 
{ 
    top:15%; 
    left:50%; 
    margin:-25px 0 0 -50px; 
    position:absolute; 
    width:100px; 
    height:50px; 
} 

/*Data Entry Page */ 
#DataEntryContent 
{ 

    position: absolute; 
    min-height: 1px; 
    height: 1000px; 
    width: 1000px; 
    -webkit-border-radius: 25px; 
    -moz-border-radius: 25px; 
    border: 1px solid; 
    margin: 10px; 
    text-align:center; 
    border-radius: 25px; 
    background: #88bfe8; /* Old browsers */ 
    background: -moz-linear-gradient(top, #88bfe8 0%, #70b0e0 100%); /* FF3.6+ */ 
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#88bfe8), color-stop(100%,#70b0e0)); /* Chrome,Safari4+ */ 
    background: -webkit-linear-gradient(top, #88bfe8 0%,#70b0e0 100%); /* Chrome10+,Safari5.1+ */ 
    background: -o-linear-gradient(top, #88bfe8 0%,#70b0e0 100%); /* Opera 11.10+ */ 
    background: -ms-linear-gradient(top, #88bfe8 0%,#70b0e0 100%); /* IE10+ */ 
    background: linear-gradient(to bottom, #88bfe8 0%,#70b0e0 100%); /* W3C */ 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#88bfe8', endColorstr='#70b0e0',GradientType=0); /* IE6-9 */ 

} 


/*General */ 
.ContentBackground 
{ 
    width: 100%; 
    height: 100%; 
    display: inline-block; 
    min-height: 1px; 
    position: absolute; 
    background: rgb(59,103,158); /* Old browsers */ 
    background: -moz-linear-gradient(45deg, rgba(59,103,158,1) 0%, rgba(43,136,217,1) 50%, rgba(32,124,202,1) 51%, rgba(125,185,232,1) 100%); /* FF3.6+ */ 
    background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,rgba(59,103,158,1)), color-stop(50%,rgba(43,136,217,1)), color-stop(51%,rgba(32,124,202,1)), color-stop(100%,rgba(125,185,232,1))); /* Chrome,Safari4+ */ 
    background: -webkit-linear-gradient(45deg, rgba(59,103,158,1) 0%,rgba(43,136,217,1) 50%,rgba(32,124,202,1) 51%,rgba(125,185,232,1) 100%); /* Chrome10+,Safari5.1+ */ 
    background: -o-linear-gradient(45deg, rgba(59,103,158,1) 0%,rgba(43,136,217,1) 50%,rgba(32,124,202,1) 51%,rgba(125,185,232,1) 100%); /* Opera 11.10+ */ 
    background: -ms-linear-gradient(45deg, rgba(59,103,158,1) 0%,rgba(43,136,217,1) 50%,rgba(32,124,202,1) 51%,rgba(125,185,232,1) 100%); /* IE10+ */ 
    background: linear-gradient(45deg, rgba(59,103,158,1) 0%,rgba(43,136,217,1) 50%,rgba(32,124,202,1) 51%,rgba(125,185,232,1) 100%); /* W3C */ 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#3b679e', endColorstr='#7db9e8',GradientType=1); /* IE6-9 fallback on horizontal gradient */ 
} 

.Line 
{ 
    clear:both; 
    width:100%; 
    min-height:1px; 
    background-color:#d1d1d1; 
    height:1px; 
    margin-top:10px; 
    margin-bottom:10px; 
} 


.Labels 
{ 

    font-size: large; 
    font-weight: bold; 
} 

.clear 
{ 
    clear: both; 
} 

.TextBoxes 
{ 
    font-size: large; 
    font-weight: bold; 
} 

.ContentBox 
{ 

    position: absolute; 
    display: inline-block; 
    -webkit-border-radius: 25px; 
    -moz-border-radius: 25px; 
    height: 1000px; 
    border: 1px solid; 
    text-align:center; 
    border-radius: 10px; 
    padding: 10px; 
    background: #88bfe8; /* Old browsers */ 
    background: -moz-linear-gradient(top, #88bfe8 0%, #70b0e0 100%); /* FF3.6+ */ 
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#88bfe8), color-stop(100%,#70b0e0)); /* Chrome,Safari4+ */ 
    background: -webkit-linear-gradient(top, #88bfe8 0%,#70b0e0 100%); /* Chrome10+,Safari5.1+ */ 
    background: -o-linear-gradient(top, #88bfe8 0%,#70b0e0 100%); /* Opera 11.10+ */ 
    background: -ms-linear-gradient(top, #88bfe8 0%,#70b0e0 100%); /* IE10+ */ 
    background: linear-gradient(to bottom, #88bfe8 0%,#70b0e0 100%); /* W3C */ 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#88bfe8', endColorstr='#70b0e0',GradientType=0); /* IE6-9 */ 

} 

#BannerImage 
{ 
    width: 297px; 
    height: 59px;  
} 


ul, li{margin:0; padding:0; list-style:none;} 

.menu_head{border:1px solid #998675;} 
.menu_body {width:184px;border-right:1px solid #998675;border-bottom:1px solid #998675;border-left:1px solid #998675;} 
.menu_body {display:none; width:184px;border-right:1px solid #998675;border-bottom:1px solid #998675;border-left:1px solid #998675;} 
.menu_body li{background:#493e3b;} 
.menu_body li a{color:#FFFFFF; text-decoration:none; padding:10px; display:block;} 
.menu_body li.alt{background:#362f2d;} 
.menu_body li a:hover{padding:15px 10px; font-weight:bold;} 

ASP站長:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="MyProject.SiteMaster" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
<head runat="server"> 
    <title>MyProject Web</title> 
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" /> 
    <link rel="stylesheet" media="screen" href="~/Styles/superfish.css" /> 
    <script type="text/javascript" src="../Scripts/jquery-1.9.1.min.js"></script> 
    <script type="text/javascript" src="../Scripts/hoverIntent.js"></script> 
    <script type="text/javascript" src="../Scripts/superfish.js"></script> 
    <script type="text/javascript" src="../Scripts/SiteMaster.js"></script> 
    <asp:ContentPlaceHolder ID="HeadContent" runat="server"> 
    </asp:ContentPlaceHolder> 
</head> 
<body> 
    <form runat="server"> 
    <div class="page"> 
     <div class="header"> 
      <div class="title"> 
      </div> 
      <div class="Banner"> 
       <img id="BannerImage" alt="Logo" src="/images/Logo.gif" /> 
       <ul class="sf-menu"> 
        <!--List for Javascript Menu --> 
       </ul>      
      </div> 
     </div> 
     <div class="ContentBackground"> 
      <asp:ContentPlaceHolder ID="MainContent" runat="server" /> 
     </div> 
    </div> 
    <div class="clear">Test</div> 
    <div class="footer"> 
     Footer 
    </div> 
    </form> 
</body> 
</html> 

頁:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Entry.aspx.cs" Inherits="MyProject.Entry.Entry" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> 
</asp:Content> 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 
<div class="ContentBox"> 
Test 
</div> 
</asp:Content> 
+2

你可以提供只是HTML和CSS,而不是ASP.net代碼?在這裏挖掘有很多可怕的東西。如果您提供一個小型自包含示例,您將得到更好的答案,其中包含**只是足夠的**代碼來演示問題,而沒有任何額外的內容。將此代碼發佈到問題中。這樣做可能需要很多工作,但它是解決問題的關鍵部分。 – KatieK

回答

1

看起來你正在運行到主要是由於發行由子元素(ContentBox)和父元素(ContentBackground)中的你的樣式表都有絕對定位。


如果你稍微修改你的CSS,應該糾正你的問題。

.ContentBackground

刪除height: 100%;position: absolute;.ContentBox


這裏刪除position: absolute;是一篇文章可以幫助您瞭解更多關於定位:http://www.barelyfitz.com/screencast/html-training/css/positioning/