<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello MUI</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!--标准mui.css-->
<link rel="stylesheet" href="../css/mui.min.css">
<!--App自定义的css-->
<link rel="stylesheet" type="text/css" href="../css/app.css"/>
<style>
/*这里的样式是为第一个行的单选框写的,其他的换行的不用*/
.radio_inline{
display: inline-block;
width: 65%;
}
.radio_inline label{
width: 20%;
padding-left: 40px;
padding-right: 40px;
}
.radio_inline input[type=radio]{
width: 15%;
right: auto;
}
/*//换个样式*/
.change .mui-radio input[type='radio']:checked:before{
content:'\e442';
color:red;
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">单选框(radio)</h1>
</header>
<div class="mui-content">
<h5 class="mui-content-padded">横着的单选框</h5>
<div class="mui-input-row ">
<label>性别</label>
<span class="radio_inline mui-radio">
<input name="radio1" type="radio" id="radio_man" checked value="1">
<label for="radio_man">男</label>
<input name="radio1" type="radio" id="radio_woman" value="0">
<label for="radio_woman">女</label>
</span>
</div>
<h5 class="mui-content-padded">单选框换个样式</h5>
<div class="mui-input-row change">
<label>性别</label>
<span class="radio_inline mui-radio">
<input name="radio1" type="radio" id="radio_man" checked value="1">
<label for="radio_man">男</label>
<input name="radio1" type="radio" id="radio_woman" value="0">
<label for="radio_woman">女</label>
</span>
</div>
<h5 class="mui-content-padded">图标左对齐</h5>
<div class="mui-card">
<form class="mui-input-group">
<div class="mui-input-row mui-radio mui-left">
<label>radio</label>
<input name="radio1" type="radio">
</div>
<div class="mui-input-row mui-radio mui-left">
<label>radio</label>
<input name="radio1" type="radio" checked>
</div>
<div class="mui-input-row mui-radio mui-left mui-disabled">
<label>disabled radio</label>
<input name="radio1" type="radio" disabled="disabled">
</div>
</form>
</div>
<h5 class="mui-content-padded">图标右对齐</h5>
<div class="mui-card">
<form class="mui-input-group">
<div class="mui-input-row mui-radio">
<label>radio</label>
<input name="radio1" type="radio">
</div>
<div class="mui-input-row mui-radio">
<label>radio</label>
<input name="radio1" type="radio" checked>
</div>
<div class="mui-input-row mui-radio mui-disabled">
<label>disabled radio</label>
<input name="radio1" type="radio" disabled="disabled">
</div>
</form>
</div>
<h5 class="mui-content-padded">列表模式的单选框</h5>
<ul class="mui-table-view mui-table-view-radio">
<li class="mui-table-view-cell">
<a class="mui-navigate-right">
Item 1
</a>
</li>
<li class="mui-table-view-cell mui-selected">
<a class="mui-navigate-right">
Item 2
</a>
</li>
<li class="mui-table-view-cell">
<a class="mui-navigate-right">
Item 3
</a>
</li>
</ul>
<div class="mui-content-padded">
<p id="info"></p>
</div>
</div>
</body>
<script src="../js/mui.min.js"></script>
<script>
mui.init({
swipeBack:true //启用右滑关闭功能
});
var info = document.getElementById("info");
document.querySelector('.mui-table-view.mui-table-view-radio').addEventListener('selected',function(e){
info.innerHTML = "当前选中的为:"+e.detail.el.innerText;
});
</script>
</html>