2010-10-05 32 views
2

繼承人的鏈接的網頁有問題的限制.... http://team2648.com/OTIS2/DivTest.html浮動DIV箱魔法

所以,如果你看一下該網頁,如果你的瀏覽器是足夠小,你看,下面用的盒子紅色背景,有一點空間,爲什麼下面的框不能浮起來?

This is what I want.

的HTML代碼:

<!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"> 
    <head> 
     <title>OTIS v1.5</title> 

     <!-- Javascript - Fix the flash of unstyled content --> 
     <script type="text/javascript"></script> 

     <!-- Stylesheets --> 
     <link href="css/reset.css" rel="stylesheet" type="text/css" media="all" /> 
     <link href="css/default.css" rel="stylesheet" type="text/css" media="screen" /> 
     <link href="css/styling.css" rel="stylesheet" type="text/css" media="screen" /> 

     <!--Validation--> 

     <script src="js/jquery.js" type="text/javascript"></script> 
     <script src="js/jquery.validationEngine-en.js" type="text/javascript"></script> 
     <script src="js/jquery.validationEngine.js" type="text/javascript"></script> 
     <link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" charset="utf-8" /> 


     <script src="js/common.js" type="text/javascript"></script> 


     <!-- Meta Information --> 
     <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> 
     <meta name="author" content="Techplex Engineer" /> 
     <meta name="keywords" content="" /> 
     <meta name="description" content="" /> 

     <script type="text/javascript"> 

      var _gaq = _gaq || []; 
      _gaq.push(['_setAccount', 'UA-10899272-10']); 
      _gaq.push(['_trackPageview']); 

      (function() { 
       var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 
       ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 
       var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 
      })(); 

     </script> 
    </head> 
    <body> 
     <div id="container"> 
      <div id="header"> 
       <div id="header-in"> 
        <h2>Online Team Information System</h2> 
        <h6>A Web Database Application for Team Profile Management</h6> 
       </div> <!-- end #header-in --> 
      </div> <!-- end #header --> 
      <div id="content-wrap" class="clear lcol"> <!-- Navigation Column--> 
       <div class="column"> 
        <div class="column-in"> 
         <ul> 
          <li> My </li> 
          <ul> 
           <li><a href="./"> Dashboard </a></li> 
           <li><a href="?page=manage.profile"> Profile</a></li> 
           <li><a href="?page=manage.info"> Information</a></li> 
           <li><a href="?page=manage.econtact"> Emergency Contact</a></li> 
          </ul> 
          <li> Management </li> 
          <ul> 
           <li><a href="?page=manage.users"> Users </a></li> 
           <li><a href="?page=email"> Email </a></li><li><a href="?page=blog"> Blog </a></li> 
          </ul> 
          <li><a href="?page=bugs.php&referrer=/OTIS2/"> Report a Bug </a></li> 
          <li><a href="logout.php"> Logout </a></li> 


         </ul> 
         <br /> 
         Logged in as: 
         <br /> 
         <a href="?page=manage.profile">Blake </a> 
        </div> 
       </div> 
       <div class="content"> 
        <div class="content-in"> 

         <h5>Welcome to your personal dashboard Blake </h5><hr id="hr1"/> 
         <div id="bio" style="display: none;"> 
          Your current Bio: <br/><textarea rows="10" cols="50"> </textarea> 
         </div> 

         <div id="profilestats" class="widget"> 
          <strong>IMPORTANT</strong><br/> 
          <ul style="padding-left: 10px;"> 
           <li>Your Public Profile is pending moderation.</li> 
          </ul> 
         </div> 

         <div id="cal" class="widget"> 
          <!-- <iframe src="https://www.google.com/calendar/hosted/team2648.com/embed?showTitle=0&amp;showNav=0&amp;showPrint=0&amp;showTabs=0&amp;showCalendars=0&amp;mode=AGENDA&amp;height=200&amp;wkst=1&amp;bgcolor=%23FFFFFF&amp;src=team2648.com_a1ur39fpp2cn076ak2q06o8hhc%40group.calendar.google.com&amp;color=%235229A3&amp;ctz=America%2FNew_York" style=" border-width:0 " width="400" height="200" frameborder="0" scrolling="no"></iframe>--> 
          <iframe src="https://www.google.com/calendar/hosted/team2648.com/embed?showNav=0&amp;showDate=0&amp;showPrint=0&amp;showTabs=0&amp;showCalendars=0&amp;showTz=0&amp;mode=AGENDA&amp;height=200&amp;wkst=1&amp;bgcolor=%23FFFFFF&amp;src=team2648.com_a1ur39fpp2cn076ak2q06o8hhc%40group.calendar.google.com&amp;color=%235229A3&amp;ctz=America%2FNew_York" style=" border-width:0 " width="400" height="200" frameborder="0" scrolling="no"></iframe> 
         </div> 
         <div id="stats" class="widget"><!-- and finally output the information formated for the widget--> 
          <strong>You have:</strong><br/> 
          <ul style="padding-left: 10px;"> 
           <li>  <strong>42</strong> of 30 fundraising hours<br/></li> 
           <li>fundraised $<strong>160</strong> of $300<br/></li> 
           <li>  <strong>3</strong> of 5 community service hours<br/></li> 
           <li>  <strong>0</strong> of 40 build hours <br/></li> 
          </ul> 
         </div> 
         <div id="logins" class="widget"> 
          <form name="controlsForm"> 
           <input id="cblogin" type="checkbox" name="loginbox" onClick=""/> Disable Login<br /> 
           <input id="cbreg" type="checkbox" name="regbox" onClick=""/> Disable Registration<br /> 
          </form> 
         </div> 

         <div class="clear"></div> 
        </div><!-- end .content-in --> 
       </div> <!-- end .content --> 
      </div> <!-- end #content-wrap --> 
      <div id="footer"> 
       <div id="footer-in"> 
        This system was designed, built and is maintained by Blake for Infinite Loop Robotics <br>OTIS(Online Team Information System) &copy; 2010 Techplex Labs  </div> <!-- end #footer-in --> 
      </div> <!-- end #footer --> 
     </div> <!-- end div#container --> 
    </body> 
</html> 

您可以查看這裏的CSS: http://team2648.com/OTIS2/css/styling.css

但相關的部分是:

div.widget{ 
width: 200px; 
float: left; 

/* text-align: center;*/ 
border: 1px solid black; 
padding: 8px; 
margin: 8px; 

/* margin-left:8px; 
font-weight:400;*/ 
-moz-border-radius:11px; 
-khtml-border-radius:11px; 
-webkit-border-radius:11px; 
border-radius:5px; 
background:#fff; 
border:2px solid #e5e5e5; 
-moz-box-shadow:rgba(200,200,200,1) 0 4px 18px; 
-webkit-box-shadow:rgba(200,200,200,1) 0 4px 18px; 
-khtml-box-shadow:rgba(200,200,200,1) 0 4px 18px; 
box-shadow:rgba(200,200,200,1) 0 4px 18px; 
/* padding:16px 16px 40px;*/ 
} 
div#disclaimer 
{ 
margin-top: 10px; 
border: 1px dotted black; 
font-size:10px; 
background-color: #D7D7D7; 
} 
div.clear 
{ 
clear: both; 
} 
div#profilestats 
{ 
border:2px solid #FF9999; 
} 
div#cal 
{ 
width: 400px; 
padding-bottom: 0px; 
} 
+0

我想你正在尋找的magicoverflow.com – 2010-10-05 16:21:55

+0

它可能是我失明,但我看到「框與紅色背景」在鏈接頁面上。 – 2010-10-05 16:27:13

+0

這似乎不是一個有效的URL。 – TechplexEngineer 2010-10-05 16:28:46

回答

1

我不知道你是否喜歡這個,但是有了評論,我發現當你把整個窗口做得更小時,帶有日曆的盒子(cal)會移動到紅色的重要盒子下面(profilestats )。

如果你希望它更接近(縮小它們之間的距離),那麼造成空間的原因是styling.css中的DIV.widget,margin:8px;除此之外,在這一點上我沒有看到任何改變 - 我在IE8中測試了這一點,並且刪除了CSS元素設置的確將它們直接推到了一起,沒有間隔。

現在,如果您的意思是將「統計信息」直接移到「profilestats」下面,那麼這是另一個可以通過幾種不同方式解決的問題。

  1. 放「profilestats」,並在一個div一起「統計」(與「CAL」和 「登錄」另一個DIV在一起,漂浮都「容器」的div留下
  2. 使用浮動:左和float:右左側和右側 元素,但是,這將介紹如果寬度是 擴展(瀏覽器的寬度),除非通過另外的CSS尋址之間的空間

在這種情況下,我會選擇#。 1,因爲css更易於控制。

注意:謹慎使用浮動左元素時IE6的邊距可能不一致。

1

之所以這種情況是因爲profilestats div和cal div都是float:left。在cal div上嘗試一個float:right;,這樣左邊浮動的下一個div(stats)可以佔用profilestats以下的可用空間。