2015-10-26 21 views
5

我知道這個堆棧上已經發布了許多關於響應表的問題,但相信我我已經通過了所有這些問題,並且還沒有找到解決方案來解決我的問題。或者,也許我不知道我在找什麼,這就是爲什麼我不得不在這裏問一個問題。在WordPress中製作響應表。

手頭的問題非常簡單。我正在製作一個WordPress的網站。我並不完全喜歡主題定價表,所以我接受了挑戰,使自己的。這裏是我的Wordpress頁面的鏈接,我需要這張表格: http://www.desklers.com/uae/undergraduate-packages

所以我的桌子很好,但我很難讓它響應。 以下是我把我的視覺作曲家的原始的HTML控件在WordPress的HTML:

<style type="text/css">  
/*General styles*/ 




/*Features table------------------------------------------------------------*/ 
@media screen and (max-width: 640px) { 
    .features-table { 
     overflow-x: auto; 
     display: block; 
    } 
} 
.features-table 
{ 
font-family:'Open Sans'; 

    margin: 0 auto; 
    border-collapse: separate; 
    border-spacing: 0; 
    text-shadow: 0 1px 0 #fff; 
    color: #2a2a2a; 
    background: #fafafa; 
    background-image: -moz-linear-gradient(top, #fff, #eaeaea, #fff); /* Firefox 3.6 */ 
    background-image: -webkit-gradient(linear,center bottom,center top,from(#fff),color-stop(0.5, #eaeaea),to(#fff)); 
} 

#check { 
color: #26CCA4; 
font-size:20px; 
} 
#cross { 
color: #E74A4A; 
font-size: 20px; 
} 
.features-table td 
{ 
    height: 50px; 
    line-height: 50px; 
    padding: 0 20px; 
    border-bottom: 1px solid #cdcdcd; 
    box-shadow: 0 1px 0 white; 
    -moz-box-shadow: 0 1px 0 white; 
    -webkit-box-shadow: 0 1px 0 white; 
    white-space: nowrap; 
    text-align: center; 
} 

/*Body*/ 
.features-table tbody td 
{ 
    text-align: center; 


} 

.features-table tbody td:first-child 
{ 
    width: auto; 
    text-align: left; 
} 

.features-table td:nth-child(2), .features-table td:nth-child(3), .features-table td:nth-child(4) 
{ 
    background: #DADADA; 
    background: #E3E3E3; 
    border-right: 1px solid white; 
} 


.features-table tr:nth-child(even) 
{ 
    background: #e7f3d4; 
    background: #E3E3E3; 
} 

/*Header*/ 
.features-table thead td 
{ 
    font-family: 'Open Sans'; 
    font-size: 16; 
    color: white; 
    line-height:16px; 
    font-weight:100; 
    font-variant:small-caps; 

    -moz-border-radius-topright: 10px; 
    -moz-border-radius-topleft: 10px; 
    border-top-right-radius: 10px; 
    border-top-left-radius: 10px; 
    border-top: 1px solid #eaeaea; 
} 

.features-table thead td:first-child 
{ 
    border-top: none; 
} 

/*Footer*/ 
.features-table tfoot td 
{ 

    -moz-border-radius-bottomright: 10px; 
    -moz-border-radius-bottomleft: 10px; 
    border-bottom-right-radius: 10px; 
    border-bottom-left-radius: 10px; 
    border-bottom: 1px solid #dadada; 
} 

.features-table tfoot td:first-child 
{ 
    border-bottom: none; 
} 




    </style> 

    <div id="main"> 

     <table class="features-table"> 
       <thead> 
        <tr> 
         <td></td> 
         <td style="background-color:#000000;"><div class="box"> 
    <div class="ribbon"><span>FEATURED</span></div><p style=" color: white; font-size:30px; font-weight:100;"> Unlimited</p></div></td> 
         <td style="background-color:#229BAA;"><p style=" color: white; font-size:30px; font-weight:100;">Premium</p></td> 
         <td style="background-color:#FEFEFE;"><p style=" color: black; font-size:30px; font-weight:100;">Basic</p></td> 
        </tr> 
       </thead> 
       <tfoot> 
        <tr> 
         <td></td> 
         <td><a class="mk-button outline-btn-dark button-562cf9ad35f16 light outline-dimension medium pointed " target="_self" href="http://www.desklers.com/uae/product/undergraduate-admission/"><span style="font-size:15px;">Get This Plan</span></a></td> 
         <td><a class="mk-button outline-btn-dark button-562cf9ad35f16 light outline-dimension medium pointed " target="_self" href="http://www.desklers.com/uae/product/undergraduate-admission/"><span style="font-size:15px;">Get This Plan</span></a></td> 
         <td><a class="mk-button outline-btn-dark button-562cf9ad35f16 light outline-dimension medium pointed " target="_self" href="http://www.desklers.com/uae/product/undergraduate-admission/"><span style="font-size:15px;">Get This Plan</span></a></td> 
        </tr> 
       </tfoot>      
       <tbody> 
        <tr> 
         <td></td> 
         <td id="price" style="background-color:#000000;">$5000</td> 
         <td id="price" style="background-color:#2BC2D5;">$3000</td> 
         <td id="price" style="background-color:#FEFEFE; color:black;">$1500</td> 
        </tr> 
        <tr id="one"> 
         <td>Number of Colleges Universities</td> 
         <td>20</td> 
         <td>10</td> 
         <td>5</td>   
        </tr> 
        <tr> 
         <td>Number of Countries you can apply</td> 
         <td>Unlimited</td> 
         <td>2</td> 
         <td>1</td>   
        </tr> 
        <tr> 
         <td>Money Back Guarantee</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>High school planning</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Academic advising and coaching</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Transcript evaluations</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Admission Documents Handling</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Guidance in SAT, ACT and Subject Tests</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>SAT, ACT and Subject Tests Preparation and Coaching</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Athletic Recruitment</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Guidance in selecting best fit colleges</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
        </tr> 
        <tr> 
         <td>Developing and finalizing a college list</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Guidance and coaching about how to write winning Application Essays and Supplements</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
        </tr> 
        <tr> 
         <td>Proof reading and feedback on College Essays and Supplements</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
        </tr> 
        <tr> 
         <td>Discussing, helping, developing and finalizing College Ideas for Essays and Supplements</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Proof Reading and finalizing Application Essays and Supplements</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Letters of Recommendation</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Leadership opportunities</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Summer strategies</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Social Work Opportunities</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Extra-Curricular activities guidance</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Guidance in Scholarship applications</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
        </tr> 
        <tr> 
         <td>Assistance in filling scholarship applications</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Guidance in CSS and other financial aid applications</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
        </tr> 
        <tr> 
         <td>Assistance in filling CSS and other financial aid applications</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Follow-ups</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 
        <tr> 
         <td>Visa Application Guidance and Handling</td> 
         <td><i class="mk-moon-checkmark" id="check"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
         <td><i class="mk-icon-remove" id="cross"></i></td> 
        </tr> 



       </tbody> 
     </table> 
    </div> 
</body> 

這裏是的jsfiddle我的代碼:https://jsfiddle.net/d96q4h3d/

使用媒體查詢,並設置溢出-x到auto,我已經能夠使我的表格能夠沿着x軸拖動。但是,我希望表格在頁面加載時顯示爲完整,以便用戶可以看到整個表格。然後他可以放大任何特定的部分,如果他想仔細看看它。

對這個問題的任何幫助將不勝感激。我在Google上做了大量的研究,但一直未能找到解釋我如何查看頁面上的完整表格的特定解決方案。

感謝

回答

3

先刪除white-space: nowrap;

現在你就必須使表最大寬度:(你想要的大小)

像本例中的最大寬度爲900px:https://jsfiddle.net/d96q4h3d/7/

,如果你想使表更小,你將不得不減少<thead>標籤的大小,以及「#price」 ID這樣

@media screen and (max-width: 800px) { 
    .features-table thead p { 
    font-size: 20px !important; 
    } 
    #price { 
    font-size: 20px; 
    } 
} 

@media screen and (max-width: 600px) { 
    .features-table thead p { 
    font-size: 15px !important; 
    } 
    #price { 
    font-size: 15px; 
    } 
    .features-table td{ 
    padding: 0px 10px; 
    } 
} 

始終把你的@media屏幕的底部的結束,而不是在頂部!

+0

到目前爲止,這似乎是最好的工作解決方案!謝謝一堆!:D 只有一個問題,無限的特色功能區似乎沒有隨着小提琴中的表一起調整大小。我怎麼能解決這個問題? –

+0

你不需要調整它的大小,因爲它已經很小了,我的意見是你需要將它移動一點,併爲標記添加一些高度,這樣它就不會太多地溢出文本。這裏是你的更新:https://jsfiddle.net/d96q4h3d/8/(你也可以從@media屏幕中刪除它,通過顯示降低600px:無) – kloshar4o

1

你有沒有考慮採用基於該Bootstrap toolkit一個WordPress theme

如果你這樣做,你可以使用this sort of pattern to emit your table,它會響應沒有各種麻煩。

<div class="table-responsive"> 
    <table class="table"> 
    your table 
    </table> 
</div> 

Bootstrap是獲得響應表和其他UI元素的一種非常好的方法;它的開發人員已經爲各種瀏覽器調試了很多東西。

+0

事情是我正在爲客戶做這個網站。我自己還不是專業人士,所以一直在試驗和學習!因此,客戶爲他的網站選擇了主題並支付了費用,因此我必須遵循它。 –

+1

該解決方案使表格(有點)響應。基本上設置'overflow-x:auto;'這會讓你能夠水平滾動表格。 –

+0

我已經能夠做到這一點。我需要的是桌子在小屏幕設備上調整大小並完全顯示在屏幕上,並且從那裏用戶可以放大桌子,但他想要的。溢出x不是解決這個問題的方法。我需要將其關閉,並找到另一種方法根據屏幕大小調整表格大小。 :/ –

1

這是一個很難解決的問題,因爲表格本身沒有響應。有很多不同的方法來達到預期的結果。許多包括使用JavaScript。

這是一個很好的綜合了不同的技術,包括一個非常聰明的純CSS(#8),這是我的最愛。

http://exisweb.net/responsive-table-plugins-and-patterns

編輯:

由於需要對整個表是在移動設備上可見,這種情況下的合適的解決方案可能是具體爲:

https://github.com/ghepting/jquery-responsive-tables - DEMO

+0

我已經到過這個頁面。 #8無效,因爲即使這樣也不會在小屏幕設備上顯示屏幕上的完整表格。由於我對JS不太舒服,所以我正在尋找一個CSS解決方案。但顯然,如果我找不到一個,那麼將不得不選擇JS :( –

+0

那麼如何通過媒體查詢縮小小設備寬度的字體呢? –

+0

或者這個:https://github.com/ghepting/jquery-響應表 –