在HBuilder中,
在标题栏上怎么添加按钮到右端?
<body>
<header class="mui-bar mui-bar-nav">
<h1 class="mui-title">标题</h1>
<button type="button" class="mui-btn mui-btn-blue">按钮</button>
<button type="button" class="mui-btn mui-btn-green">按钮 </button>
</header>
</body>
l***@126.com
- 发布:2016-11-25 14:51
- 更新:2018-01-29 16:00
- 阅读:7086
刚好做了功能,官方的没看到类似的例子所以自己写了,大概就是如果要居于右侧,那就设置float:right,这样就可以了,html代码如下:
<header class="mui-bar mui-bar-nav">
<h1 id="edit" class="title-left">编辑</h1>
<h1 id="title" class="mui-title">自选</h1>
<span class="title-right mui-icon mui-icon-search"></span>
</header>
css的代码如下,这一段放在mui.min.css文件中即可:
/标题中图标居右侧的css样式/
/*标题中图标居左侧的css样式*/
.title-left {
float: left;
font-size: 17px;
font-weight: 500;
line-height: 44px;
position: absolute;
display: block;
width: 100%;
margin: 0 -10px;
padding: 0;
text-align: center;
white-space: nowrap;
color: #000;
display: inline-block;
overflow: hidden;
width: auto;
margin: 0;
text-overflow: ellipsis;
}
/*标题中图标居右侧的css样式*/
.title-right {
float: right;
font-size: 17px;
font-weight: 500;
line-height: 44px !important;
position: absolute;
display: block;
width: 100%;
margin: 0 0px !important;
padding: 0 !important;
text-align: center;
white-space: nowrap;
color: #000;
display: inline-block;
overflow: hidden;
width: auto;
margin: 0;
text-overflow: ellipsis;
}
运行结果如下: