Header bar with a segmented control

Description

A segmented control is an inline set of controls that each display a different view.

It is recommended to position the segmented control within the main header.

Example


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Segmented Control Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
  href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<style>
.segmented-control {<!--from  w  ww .j  ava2  s. co  m-->
  text-align: center;
}

.segmented-control .ui-controlgroup {
  margin: 0.2em;
}

.ui-control-active, .ui-control-inactive {
  border-style: solid;
  border-color: gray;
}

.ui-control-active {
  background: #BBB;
}

.ui-control-inactive {
  background: #DDD;
}
</style>
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
</head>
<body>

  <div data-role="page">
    <div data-role="header" data-position="fixed">
      <h1>Movies</h1>
      <div class="segmented-control ui-bar-d">
        <div data-role="controlgroup" data-type="horizontal">
          <a href="#" data-role="button" class="ui-control-active">In
            Theatres</a> <a href="#" data-role="button"
            class="ui-control-inactive">Coming Soon</a> <a href="#"
            data-role="button" class="ui-control-inactive">Top Rated</a>
        </div>
      </div>
    </div>

    <div data-role="content">
      <ul data-role="listview">
        <li><a href="#"> <img src="http://placehold.it/50x50" />
            <h3>Kung Fu Panda</h3>
            <p>Rated: PG</p>
            <p>Runtime: 95 min.</p>
        </a></li>
        <li><a href="#"> <img src="http://placehold.it/50x50" />
            <h3>Pirates of the Caribbean</h3>
            <p>Rated: PG-13</p>
            <p>Runtime: 137 min.</p>
        </a></li>
        <li><a href="#"> <img src="http://placehold.it/50x50" />
            <h3>X-Men</h3>
            <p>Rated: PG-13</p>
            <p>Runtime: 131 min.</p>
        </a></li>
        <li><a href="#"> <img src="http://placehold.it/50x50" />
            <h3>Kung Fu Panda 3D</h3>
            <p>Rated: PG</p>
            <p>Runtime: 95 min.</p>
        </a></li>
      </ul>
    </div>
  </div>

</body>
</html>

Click to view the demo





















Home »
  jQuery Mobile »
    Tutorial »




jQuery_Mobile
Form
List
Layout
Theme