Autolycus Autolycus - 1 year ago 91
jQuery Question

jquery UI tabs width 100%

enter image description hereI have a need to use only 2 tabs in my application. So I want them to cover 100% of the width. Currently it aligns both tabls on left side and leave all kind of empty space on right side. What can I do so that both of my tabs cover 100% of the area.
I am using jquery-ui-1.8.17.custom.css


<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="" />
<script src=""></script>
<script src=""></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">


// Tabs



<div data-role="page">

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

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

<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><!-- /content -->

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


Answer Source

Via CSS set:

.ui-tabs .ui-tabs-nav li {

Note due to padding, margins, and borders you may need to reduce it to less than 50%.

Update: If you want to center the text in the tabs, you need to make two CSS changes (keeping the 50% change from above).

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

Note that you can tweak the padding as needed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download