2016-12-06 54 views
1

我想問一問,如何更改jQuery Mobile中「可摺疊」的顏色? 我只想將辦公室A線替換爲紅色,而辦公室B變爲綠色,只有可摺疊的頭單獨。更改顏色collapsibleset jquery移動

<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <!-- Include meta tag to ensure proper rendering and touch zooming --> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"> 
 
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> 
 
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> 
 
    <style> 
 
     /* Start with core styles outside of a media query that apply to mobile and up */ 
 
     /* Global typography and design elements, stacked containers */ 
 
     
 
     body { 
 
      font-family: Helvetica, san-serif; 
 
     } 
 
     
 
     H1 { 
 
      color: green; 
 
     } 
 
     
 
     a:link { 
 
      color: purple; 
 
     } 
 
     /* Stack the two content containers */ 
 
     
 
     .main, 
 
     .sidebar { 
 
      display: block; 
 
      width: 100%; 
 
     } 
 
     /* First breakpoint at 576px */ 
 
     /* Inherits mobile styles, but floats containers to make columns */ 
 
     
 
     @media all and (min-width: 36em) { 
 
      .main { 
 
       float: left; 
 
       width: 60%; 
 
      } 
 
      .sidebar { 
 
       float: left; 
 
       width: 40%; 
 
      } 
 
     } 
 
     /* Second breakpoint at 800px */ 
 
     /* Adjusts column proportions, tweaks base H1 */ 
 
     
 
     @media all and (min-width: 50em) { 
 
      .main { 
 
       width: 70%; 
 
      } 
 
      .sidebar { 
 
       width: 30%; 
 
      } 
 
      /* You can also tweak any other styles in a breakpoint */ 
 
      H1 { 
 
       color: black; 
 
       font-size: 1.2em 
 
      } 
 
     } 
 
     /* Multi Count */ 
 
     
 
     .count-second { 
 
      right: 90px !important; 
 
     } 
 
     
 
     .color1 { 
 
      background-color: red !important; 
 
     } 
 
     
 
     .color2 { 
 
      background-color: green !important; 
 
     } 
 
     /* HEADER COLOR */ 
 
     
 
     .custom-navbar ul li a { 
 
      background: #3388CC; 
 
      /* Old browsers */ 
 
      background: linear-gradient(#3388CC, #3388CC) repeat scroll 0 0 #3388CC !important; 
 
      background: -moz-linear-gradient(#3388CC, #3388CC) repeat scroll 0 0 #3388CC !important; 
 
      /* FF3.6+ */ 
 
      background: -webkit-linear-gradient(#3388CC, #3388CC) repeat scroll 0 0 #3388CC !important; 
 
      /* Chrome10+,Safari5.1+ */ 
 
      background: -o-linear-gradient(#3388CC, #3388CC) repeat scroll 0 0 #3388CC !important; 
 
      /* Opera 11.10+ */ 
 
      background: -ms-linear-gradient(#3388CC, #3388CC) repeat scroll 0 0 #3388CC !important; 
 
      /* IE10+ */ 
 
      filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#3388CC', endColorstr='#3388CC', GradientType=0); 
 
      /* IE6-9 */ 
 
     } 
 
    </style> 
 
    <script> 
 
     $(document).on('pagebeforeshow', '#index', function() { 
 
      console.log("init"); 
 
     }); 
 
    </script> 
 
</head> 
 

 
<body> 
 
    <div data-role="page" id="pageone"> 
 
     <div data-role="header"> 
 
      <h1>GSM 2DZ1</h1> 
 
     </div> 
 
     <div data-role="main" class="ui-content"> 
 
      <a href="../modem-m.php" class="ui-btn">MODEM TELPON</a> 
 
     </div> 
 
     <div data-theme="b" data-role="header"> 
 
      <div data-role="navbar" data-iconpos="left" class="custom-navbar"> 
 
       <ul> 
 

 
        <li> 
 
         <a href='' data-prefetch='true' rel='external' data-icon='check'>GSM ON 2 TOKO \t \t \t \t 
 
\t \t \t \t </a></li> 
 

 
       </ul> 
 
      </div> 
 
     </div> 
 
     <div data-role="collapsibleset" data-inset="true"> 
 
      <div data-mini="true" data-role="collapsible" data-theme="b" data-content-theme="a" data-collapsed-icon="delete" data-expanded-icon="bars"> 
 
       <h3> 
 
        1. OFFICE A 
 
        <span class="ui-li-count">O 8 det</span> 
 
        <span class="ui-li-count count-second">C 8 det</span> 
 
       </h3> 
 
       <h4> 
 
        OFFICE A </h4> 
 
       <ul data-role="listview" data-inset="true"> 
 
        <li>IP : 1.2.3.4</li> 
 
        <li>LATENCY : 1,499 s</li> 
 
        <li>ONLINE : 8 detik lalu</li> 
 
        <li>DICEK : 8 detik lalu</li> 
 
        <li> 
 
         KONEKSI KARTU GSM 
 
        </li> 
 
       </ul> 
 
      </div> 
 
      <div data-mini="true" data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="check" data-expanded-icon="bars"> 
 
       <h3> 
 
        2. OFFICE B 
 
        <span class="ui-li-count">O 6 det</span> 
 
        <span class="ui-li-count count-second">C 6 det</span> 
 
       </h3> 
 
       <h4> 
 
        OFFICE B </h4> 
 
       <ul data-role="listview" data-inset="true"> 
 
        <li>IP : 1.2.3.5</li> 
 
        <li>LATENCY : 1,797 s</li> 
 
        <li>ONLINE : 6 detik lalu</li> 
 
        <li>DICEK : 6 detik lalu</li> 
 
        <li> 
 
         KONEKSI KARTU GSM 
 
        </li> 
 
       </ul> 
 
      </div> 
 
     </div> 
 

 
     <div data-role="footer"> 
 
      <h1>2016 &copy; 2DZ1 - BATAM</h1> 
 
     </div> 
 
    </div> 
 

 
</body> 
 

 
</html>

回答

1

爲了使這項工作,你應該添加以下CSS:

#officeACollap.ui-collapsible .ui-btn{ 
background-color: red !important; 
} 

UI可摺疊和UI-BTN是被添加到 類可摺疊div

「officeACollap」是我必須添加到第一個Collapsible才能更改此可摺疊的顏色的ID。

編輯:您可能不需要CSS的「!important」部分。

<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <!-- Include meta tag to ensure proper rendering and touch zooming --> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"> 
 
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> 
 
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> 
 
    <style> 
 
     /* Start with core styles outside of a media query that apply to mobile and up */ 
 
     /* Global typography and design elements, stacked containers */ 
 
     
 
     body { 
 
      font-family: Helvetica, san-serif; 
 
     } 
 
     
 
     H1 { 
 
      color: green; 
 
     } 
 
     
 
     a:link { 
 
      color: purple; 
 
     } 
 
     /* Stack the two content containers */ 
 
     
 
     .main, 
 
     .sidebar { 
 
      display: block; 
 
      width: 100%; 
 
     } 
 
     /* First breakpoint at 576px */ 
 
     /* Inherits mobile styles, but floats containers to make columns */ 
 
     
 
     @media all and (min-width: 36em) { 
 
      .main { 
 
       float: left; 
 
       width: 60%; 
 
      } 
 
      .sidebar { 
 
       float: left; 
 
       width: 40%; 
 
      } 
 
     } 
 
     /* Second breakpoint at 800px */ 
 
     /* Adjusts column proportions, tweaks base H1 */ 
 
     
 
     @media all and (min-width: 50em) { 
 
      .main { 
 
       width: 70%; 
 
      } 
 
      .sidebar { 
 
       width: 30%; 
 
      } 
 
      /* You can also tweak any other styles in a breakpoint */ 
 
      H1 { 
 
       color: black; 
 
       font-size: 1.2em 
 
      } 
 
     } 
 
     /* Multi Count */ 
 
     
 
     .count-second { 
 
      right: 90px !important; 
 
     } 
 
     
 
     .color1 { 
 
      background-color: red !important; 
 
     } 
 
     
 
     .color2 { 
 
      background-color: green !important; 
 
     } 
 
     /* HEADER COLOR */ 
 
     
 
     .custom-navbar ul li a { 
 
      background: #3388CC; 
 
      /* Old browsers */ 
 
      background: linear-gradient(#3388CC, #3388CC) repeat scroll 0 0 #3388CC !important; 
 
      background: -moz-linear-gradient(#3388CC, #3388CC) repeat scroll 0 0 #3388CC !important; 
 
      /* FF3.6+ */ 
 
      background: -webkit-linear-gradient(#3388CC, #3388CC) repeat scroll 0 0 #3388CC !important; 
 
      /* Chrome10+,Safari5.1+ */ 
 
      background: -o-linear-gradient(#3388CC, #3388CC) repeat scroll 0 0 #3388CC !important; 
 
      /* Opera 11.10+ */ 
 
      background: -ms-linear-gradient(#3388CC, #3388CC) repeat scroll 0 0 #3388CC !important; 
 
      /* IE10+ */ 
 
      filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#3388CC', endColorstr='#3388CC', GradientType=0); 
 
      /* IE6-9 */ 
 
     } 
 
     #officeACollap.ui-collapsible .ui-btn{ 
 
      background-color: red !important; 
 
     } 
 
    </style> 
 
    <script> 
 
     $(document).on('pagebeforeshow', '#index', function() { 
 
      console.log("init"); 
 
     }); 
 
    </script> 
 
</head> 
 

 
<body> 
 
    <div data-role="page" id="pageone"> 
 
     <div data-role="header"> 
 
      <h1>GSM 2DZ1</h1> 
 
     </div> 
 
     <div data-role="main" class="ui-content"> 
 
      <a href="../modem-m.php" class="ui-btn">MODEM TELPON</a> 
 
     </div> 
 
     <div data-theme="b" data-role="header"> 
 
      <div data-role="navbar" data-iconpos="left" class="custom-navbar"> 
 
       <ul> 
 

 
        <li> 
 
         <a href='' data-prefetch='true' rel='external' data-icon='check'>GSM ON 2 TOKO \t \t \t \t 
 
\t \t \t \t </a></li> 
 

 
       </ul> 
 
      </div> 
 
     </div> 
 
     <div data-role="collapsibleset" data-inset="true"> 
 
      <div id="officeACollap" data-mini="true" data-role="collapsible" data-theme="b" data-content-theme="a" data-collapsed-icon="delete" data-expanded-icon="bars"> 
 
       <h3> 
 
        1. OFFICE A 
 
        <span class="ui-li-count">O 8 det</span> 
 
        <span class="ui-li-count count-second">C 8 det</span> 
 
       </h3> 
 
       <h4> 
 
        OFFICE A </h4> 
 
       <ul data-role="listview" data-inset="true"> 
 
        <li>IP : 1.2.3.4</li> 
 
        <li>LATENCY : 1,499 s</li> 
 
        <li>ONLINE : 8 detik lalu</li> 
 
        <li>DICEK : 8 detik lalu</li> 
 
        <li> 
 
         KONEKSI KARTU GSM 
 
        </li> 
 
       </ul> 
 
      </div> 
 
      <div data-mini="true" data-role="collapsible" data-theme="a" data-content-theme="a" data-collapsed-icon="check" data-expanded-icon="bars"> 
 
       <h3> 
 
        2. OFFICE B 
 
        <span class="ui-li-count">O 6 det</span> 
 
        <span class="ui-li-count count-second">C 6 det</span> 
 
       </h3> 
 
       <h4> 
 
        OFFICE B </h4> 
 
       <ul data-role="listview" data-inset="true"> 
 
        <li>IP : 1.2.3.5</li> 
 
        <li>LATENCY : 1,797 s</li> 
 
        <li>ONLINE : 6 detik lalu</li> 
 
        <li>DICEK : 6 detik lalu</li> 
 
        <li> 
 
         KONEKSI KARTU GSM 
 
        </li> 
 
       </ul> 
 
      </div> 
 
     </div> 
 

 
     <div data-role="footer"> 
 
      <h1>2016 &copy; 2DZ1 - BATAM</h1> 
 
     </div> 
 
    </div> 
 

 
</body> 
 

 
</html>

+0

感謝。它的工作,謝謝你的幫助:) –

+0

如果這個答案是解決你的問題,你可以接受它,如果你想 – TheWandererr