2012-05-27 55 views
0

我正在做一個大學項目。我需要將滾動位置從「水平」更改爲「垂直」,但這不起作用。這裏我使用PHP和HTML,CSS。請問任何人可以修理我的代碼嗎?我對css很陌生。如何改變溢出?

這是我的電流輸出:

My Current Output In IMAGE format

我的代碼:

<style> 
div.boxx 
{ 
    background-color:#9C0; 
    width:150px; 
    height:150px; 
    margin-left:20px; 
    text-align:center; 
    float:left; 
} 

div.boxx:hover 
{ 
    background:#333; 
} 

div.inside1 
{ 

    width:100px; 
    height:100px; 
    margin-left:auto; 
    margin-right:auto; 
    position:relative; 
    margin-top:10px; 
    bottom:0px; 
    border:solid #666; 
    border-width:thin; 
} 

div.inside2 
{ 

    width:auto; 
    height:40px; 
    margin-left:auto; 
    margin-right:auto; 
    margin-top:5px; 
    text-align:center; 
} 

div.button1 
{ 
    width:15px; 
    height:25px; 
    left:85px; 
    float:right; 
    position:absolute; 
    top:0px; 
} 

table.main_table 
{ 
    margin-left:auto; 
    margin-right:auto; 
    width:auto; 
} 

tr.toptr 
{ 
    background:url(images/available_gallary_top.png) no-repeat; 
    height:38px; 
} 

tr.boatamtr 
{ 
    background:url(images/available_gallary_bottam.png) no-repeat; 
    height:7px; 
} 

tr.fulltr 
{ 
    background:url(images/available_gallary_bg.png) repeat-y; 
} 

div.gal_cantiner 
{ 
    background-color:#09C; 
    width:869px; 
    margin-left:2px; 
    height:152px; 
    overflow:auto; 
} 

input.delet_gal_bt 
{ 
    width:13px; 
    height:13px; 
    background:url(images/delet_gal_bt.png) no-repeat; 
    border:none; 
} 
input.delet_gal_bt:hover 
{ 
    background:url(images/delet_gal_bt_h.png) no-repeat; 
} 

input.remove_gal_bt 
{ 
    width:13px; 
    height:13px; 
    background:url(images/remove_gal_bt.png) no-repeat; 
    border:none; 
} 
input.remove_gal_bt:hover 
{ 
    background:url(images/remove_gal_bt_h.png) no-repeat; 
} 

span.gallary_date_text 
{ 
    color:#666; 
    font-size:9px; 
    line-height:15px; 
} 


</style> 
<?php 
session_start(); 
include "config.php"; 
error_reporting(0); 
echo "<br>"; 
$crt=0; 
$sql= mysql_query("SELECT * FROM new_gallary",$con); 
echo "<table class='main_table' border='0' align='center'><tr class='toptr'><td>&nbsp;</td></tr><tr class='fulltr'><td><div class='gal_cantiner' id='gal_cantiner'>"; 
while($row = mysql_fetch_array($sql)) 
    { 

     echo "<div class='boxx' id='boxx".$crt."'><div class='inside1'><img src='".$galimg."' width='100' height='100'><div class='button1'><input type='button' class='delet_gal_bt' onclick='deleted_gallary(".$row['id'].")'/><input type='button' class='remove_gal_bt' onclick='remove_for_gallary(".$row['id'].")'/></div></div><div class='inside2'>".$row['gallary_name']."<br><span class='gallary_date_text'>".$row['gallary_date']."</span></div></div>"; 

     $crt++; 
    } 
echo "</div></td></tr><tr class='boatamtr'><td></td></tr></table>"; 
?> 
+0

「我需要改變滾動位置水平到垂直」。這個例子已經顯示了一個垂直滾動條,你需要添加一個水平你的意思,與一個可能的固定表寬度? – 2012-05-27 12:01:22

+1

我修復了你的英文。但是你的代碼需要修復。 – Katti

+1

@ katti謝謝卡蒂! – pram

回答

2

我終於找到了答案。我添加一個新的風格行成tr是會喜歡這個循環裏面:

$l=$l+100; 
echo" 
    <div class='boxx' id='boxx".$crt."' style="margin-left:".$l."px;margin-top:-160px;"> 
     <div class='inside1'> 
      <img src='".$galimg."' width='100' height='100'> 
      <div class='button1'> 
       <input type='button' class='delet_gal_bt' onclick='deleted_gallary(".$row['id'].")'/> 
       <input type='button' class='remove_gal_bt' onclick='remove_for_gallary(".$row['id'].")'/> 
      </div> 
     </div> 
     <div class='inside2'>".$row['gallary_name']."> 
      <br> 
      <span class='gallary_date_text'>".$row['gallary_date']."</span> 
     </div> 
    </div> 
"; 

style="margin-left:".$l."px; margin-top:-160px; 

最終輸出:Image

+0

div.gal_cantiner {overflow:auto;}已經在auto中,但div.boxx在float:left中,所以主gal_cantiner div不是水平的。然後我改變每個div保證金左邊的位置例如:100,200,300每個移動水平然後溢出:汽車是工作的! – pram

0

試試這個。

overflow: auto; 
overflow-x: hidden; 

並請剪短代碼:sscce

+0

謝謝。但我嘗試這一個它不工作! div.gal_cantiner { \t background-color:#09C; \t width:869px; \t margin-left:2px; \t height:152px; \t溢出:auto; overflow-x:hidden; } – pram

0

@ user1126301你的代碼似乎並不具有任何滾動條。它只是使用現有的圖像。

你應該在你的CSS補充一點:

overflow-y: scroll; overflow-x: hidden; padding-right: 5px; 
visibility: visible; border: thin solid white; background-color:#336699; 
scrollbar-face-color: #336699; scrollbar-3dlight-color: #336699; 
scrollbar-base-color: #336699; scrollbar-track-color: #336699; 
scrollbar-darkshadow-color: #000; scrollbar-arrow-color: #000; 
scrollbar-shadow-color: #fff; scrollbar-highlight-color: #fff; 
+0

謝謝。我只需要爲div.gal_cantiner滾動。但我嘗試你的代碼不工作!它給出相同的輸出! – pram

+0

試試這個:div.gal_cantiner {style =「width:100px; height:100px; overflow-x:hidden; overflow-y:scroll; background-color:#000000」} – SKL

+0

no..still same output but div .gal_cantiner現在更小.. – pram