我正在使用Bootstrap
,我希望我的表具有應用於移動視圖的table-condensed
類,以及應用於移動大小以上的table-responsive
類。在移動視圖中更改表類?
什麼是最好的方法呢?有沒有辦法在SASS
中做到這一點?
我剛剛在SASS
中偶然發現'extend
',但我不認爲這是我所需要的,因爲當我嘗試實現它時,我無法在媒體查詢中使用它,工作確定
謝謝:)
(我在努力嘗試,包括我的代碼,但我得到一個錯誤)
我正在使用Bootstrap
,我希望我的表具有應用於移動視圖的table-condensed
類,以及應用於移動大小以上的table-responsive
類。在移動視圖中更改表類?
什麼是最好的方法呢?有沒有辦法在SASS
中做到這一點?
我剛剛在SASS
中偶然發現'extend
',但我不認爲這是我所需要的,因爲當我嘗試實現它時,我無法在媒體查詢中使用它,工作確定
謝謝:)
(我在努力嘗試,包括我的代碼,但我得到一個錯誤)
你可以使用jQuery調整功能
例如
$(window).resize(function() {
var screenwidth = $(document).width();
if(screewidth <= 480)
{
$("#table").removeClass("table-responsive");
$("#table").addClass("table-condensed");
}
else
{
$("#table").removeClass("table-condensed");
$("#table").addClass("table-responsive");
}
});
如果您正在使用SASS您可以在移動使用媒體查詢時指定表的屬性:
SASS:
$break-small: 320px;
$break-large: 1200px;
.table {
//Default table properties
@media screen and (max-width: $break-small) {
//small screen size table properties
}
@media screen and (min-width: $break-large) {
//Large screen size table properties
}
}
如果您正在使用CSS:
table{
//Regular table properties
}
@media screen and (min-width: 480px) {
//small screen size table properties
}
即使有人能指向我的一些關鍵字的方向來搜索我會非常感激它,我認爲我的問題是我沒有搜索正確的關鍵字/短語來獲得我正在尋找的答案 – arieii