2012-02-10 26 views
10

enter image description here मुझे अपने आवेदन में केवल 2 टैब का उपयोग करने की आवश्यकता है। तो मैं चाहता हूं कि वे चौड़ाई के 100% को कवर करें। वर्तमान में यह बाईं ओर दोनों टैबलेट को संरेखित करता है और दाईं तरफ सभी प्रकार की खाली जगह छोड़ देता है। मैं क्या कर सकता हूं ताकि मेरे दोनों टैब क्षेत्र के 100% को कवर कर सकें। मैं उपयोग कर रहा हूँ jQuery-ui-1.8.17.custom.cssjquery UI टैब चौड़ाई 100%

कोड

<!DOCTYPE html> 
<html> 
    <head> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" /> 
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> 
    <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script> 
     <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.17.custom.css" rel="stylesheet" /> 
     <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script> 
     <script type="text/javascript" src="js/jquery-ui-1.8.17.custom.min.js"></script> 
     <script type="text/javascript"> 

      $(function(){ 


       // Tabs 
       $('#tabs').tabs(); 


      }); 
     </script> 

    </head> 
    <body> 

    <div data-role="page"> 

    <div data-role="header"> 
     <h1>My Title</h1> 
    </div><!-- /header --> 

    <div data-role="content"> 
      <div id="tabs"> 
      <ul> 
       <li><a href="#tabs-1">First</a></li> 
       <li><a href="#tabs-2">Second</a></li> 

      </ul> 
      <div id="tabs-1">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div> 
      <div id="tabs-2">Phasellus mattis tincidunt nibh. Cras orci urna, blandit id, pretium vel, aliquet ornare, felis. Maecenas scelerisque sem non nisl. Fusce sed lorem in enim dictum bibendum.</div> 
       </div> 

    </div><!-- /content --> 

</div><!-- /page --> 
     <!-- Tabs --> 




    </body> 
</html> 
+0

कुछ मार्कअप को देखने का कोई मौका? – pete

+0

यकीन है, मुझे एक सेकंड दें – Autolycus

उत्तर

14

वाया सीएसएस सेट:

.ui-tabs .ui-tabs-nav li { 
    width:50%; 
} 

गद्दी, मार्जिन, और सीमाओं आप की आवश्यकता हो सकती की वजह से नोट इसे 50% से कम करने के लिए।

अद्यतन: यदि आप टैब में टेक्स्ट को केंद्र में रखना चाहते हैं, तो आपको दो सीएसएस परिवर्तन करना होगा (ऊपर से 50% परिवर्तन रखना)।

.ui-tabs .ui-tabs-nav li { 
    width:50%; 
    text-align: center; 
} 
.ui-tabs .ui-tabs-nav li a { 
    display: inline-block; 
    float: none; 
    padding: 5px; 
    text-decoration: none; 
    width: 100%; 
} 

ध्यान दें कि आप आवश्यकतानुसार पैडिंग को ट्विक कर सकते हैं।

+0

क्या मैं jquery css में बदलता हूं? – Autolycus

+0

अच्छा! बस । हालांकि मैं उन्हें कैसे केन्द्रित करूं? – Autolycus

+2

आप jQuery UI सीएसएस को संशोधित कर सकते हैं या इसके बाद अपना स्वयं का सीएसएस जोड़ सकते हैं क्योंकि इससे पहले घोषित किसी भी नियम को ओवरराइड कर दिया जाएगा। – j08691

1

flexbox के साथ यह लचीला और आसान है:

.ui-tabs .ui-tabs-nav { 
    display: flex; 
} 

.ui-tabs .ui-tabs-nav li { 
    flex: 1; 
    display: flex; 
    /* If placed in a small width sidebar or something like that disabling nowrap will fix the overflow issue */ 
    white-space: normal; 
} 

.ui-tabs .ui-tabs-nav li a { 
    flex: 1; 
    /* If you want to align tab titles center */ 
    text-align: center; 
} 

When the default jquery-ui tab is put on normal or larger width place

When it's put a on smaller width place

+0

मेरे लिए बहुत अच्छा काम करता है, और क्लीनर – cycle4passion

संबंधित मुद्दे