Custom Theme

Description

We can explicitly set the themes of our individual components.

Example


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Themes</title>
<meta name="viewport"
  content="width=device-width, minimum-scale=1, maximum-scale=1">
<link rel="stylesheet"
  href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<style>
label {<!--from   w w w.j  av  a2 s. co m-->
  float: left;
  width: 5em;
}

input.ui-input-text {
  display: inline !important;
  width: 10em !important;
}

form p {
  clear: left;
  margin: 1px;
}
</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" data-theme="e">
    <div data-role="header" data-theme="b">
      <h1>Theme = "b"</h1>
    </div>

    <div data-role="content" data-theme="d"
      style="text-align: center; margin-top: 5px;">
      Theme = "d"

      <ul data-role="listview" data-inset="true" data-theme="e"
        data-divider-theme="e">
        <li data-role="list-divider">Theme = "e"</li>
        <li>Inherits "e" from list</li>
        <li data-theme="b">Theme = "b"</li>
      </ul>

      <form id="test" id="test" action="#" method="post">
        <p>
          <label for="text">Theme "d"</label>
          <input type="text" name="text"
            id="text" value="" data-theme="d" placeholder="Text input" />
        </p>
        <p>
          <label for="sound">Theme "b"</label>
          <select name="slider"
            id="sound" data-role="slider" data-theme="b">
            <option value="off">Off</option>
            <option value="on">On</option>
          </select>
        </p>

        <a href="#" data-role="button" data-theme="a">Button (Theme ="a")</a>
      </form>
    </div>

    <div data-role="footer" data-position="fixed" data-theme="b">
      <h3>Theme = "b"</h3>
    </div>
  </div>
</body>
</html>

Click to view the demo

Example 2


<!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/jquery.mobile-1.0.min.css" />
<style>
.tabbar .ui-btn .ui-btn-inner {<!--from  www. j av a2s. co m-->
  font-size: 11px !important;
  padding-top: 24px !important;
  padding-bottom: 0px !important;
}

.tabbar .ui-btn .ui-icon {
  width: 30px !important;
  height: 20px !important;
  margin-left: -15px !important;
  box-shadow: none !important;
  -moz-box-shadow: none !important;
  -webkit-box-shadow: none !important;
  -webkit-border-radius: none !important;
  border-radius: none !important;
}

#home .ui-icon {
  background: url(http://placehold.it/50x50) 50% 50% no-repeat;
  background-size: 22px 20px;
}

#movies .ui-icon {
  background: url(http://placehold.it/50x50) 50% 50% no-repeat;
  background-size: 25px 17px;
}

#theatres .ui-icon {
  background: url(http://placehold.it/50x50) 50% 50% no-repeat;
  background-size: 20px 20px;
}

.segmented-control {
  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-theme="d" data-position="fixed">
      <div class="segmented-control ui-bar-d">
        <div data-role="controlgroup" data-type="horizontal">
          <a href="#" data-role="button" class="ui-control-active">In Stores</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" data-split-icon="delete"
        data-split-theme="v">
        <li><a href="#">
            <h3>CSS</h3>
            <p>Rated: A</p>
            <p>Runtime: 95 min.</p>
        </a> <a href="#delete" data-transition="slidedown">Delete</a></li>
        <li><a href="#">
            <h3>HTML</h3>
            <p>Rated: B</p>
            <p>Runtime: 137 min.</p>
        </a> <a href="#delete" data-transition="slidedown">Delete</a></li>
      </ul>
    </div>

    <!-- tab bar with custom icons -->
    <div data-role="footer" class="tabbar" data-position="fixed">
      <div data-role="navbar" class="tabbar">
        <ul>
          <li><a href="#" id="home" data-icon="custom">Home</a></li>
          <li><a href="#" id="movies" data-icon="custom"
            class="ui-btn-active">Movies</a></li>
          <li><a href="#" id="theatres" data-icon="custom">Stores</a></li>
        </ul>
      </div>
    </div>
  </div>

  <div data-role="dialog" id="delete">
    <div data-role="content" data-theme="c">
      <span class="title">Are you sure?</span>
      <a href="#home" data-role="button" data-theme="v">Delete</a>
      <a href="#home" data-role="button" data-theme="c" data-rel="back">Cancel</a>
    </div>
    <style>
        span.title {
          display: block;
          text-align: right;
          margin-top: 15px;
          margin-bottom: 20px;
        }
        </style>
  </div>
</body>
</html>

Click to view the demo





















Home »
  jQuery Mobile »
    Tutorial »




jQuery_Mobile
Form
List
Layout
Theme