小程序中圆角边框的设置
2017-01-09 17:59
801 查看
与CSS一样,小程序中的圆角可以通过border-radius来设置。
以input为例,想要设置圆角边框,只需加上如下样式:
即可实现如下效果:
不同的是,在小程序中想要设置仅其中某个圆角,而其它为直角,则需要使用 border-bottom-left-radius, border-top-left-radius, border-bottom-left-radius, border-top-left-radius单独设置,使用类似于CSS中的直接在border-radius属性中写四个值,如:border-radius: 5px,0px,0px,5px; 则没有效果
以下是设置左半边为圆角,右半边为直角的情况:
另外,小程序中按钮button是自带圆角的,
因此如果想设置仅一半显示圆角,需如下设置:
效果如下:
据此我们可以生成一个带圆角边框的搜索栏:
wxml
wxss
当然对于本身不带边框的组件,如label,view等,注意要配合border属性使用才能显示出圆角边框的效果。
以input为例,想要设置圆角边框,只需加上如下样式:
border-radius: 5px
即可实现如下效果:
不同的是,在小程序中想要设置仅其中某个圆角,而其它为直角,则需要使用 border-bottom-left-radius, border-top-left-radius, border-bottom-left-radius, border-top-left-radius单独设置,使用类似于CSS中的直接在border-radius属性中写四个值,如:border-radius: 5px,0px,0px,5px; 则没有效果
以下是设置左半边为圆角,右半边为直角的情况:
border-bottom-left-radius: 5px; border-top-left-radius: 5px;
另外,小程序中按钮button是自带圆角的,
因此如果想设置仅一半显示圆角,需如下设置:
border-radius: 0px; border-bottom-right-radius: 5px; border-top-right-radius: 5px;
效果如下:
据此我们可以生成一个带圆角边框的搜索栏:
wxml
<view class="search-cell"> <view class="weui-cell__bd"> <input class="input-search" placeholder="" value="{{inputVal}}"/> </view> <view class="weui-cell__ft"> <button class="btn-search" type="primary" >搜索</button> </view> </view>
wxss
.btn-search { border-radius: 0px; border-bottom-right-radius: 5px; border-top-right-radius: 5px; font-size: 13px; font-family: "微软雅黑"; } .input-search { border: lightgrey; border-style: solid; border-width: 1px; font-size: 14px; border-bottom-left-radius: 5px; border-top-left-radius: 5px; height: 31px; padding-left: 10px; } .search-cell { margin-top: 30px; position: relative; display: -webkit-box; display: -webkit-flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; }
当然对于本身不带边框的组件,如label,view等,注意要配合border属性使用才能显示出圆角边框的效果。
相关文章推荐
- 小程序中圆角边框的设置
- GradientDrawable 可以用来通过程序方式给控件设置背景如圆角,边框等
- 小程序中圆角边框的设置
- winform 窗体设置成无边框、可拖拽、四周圆角
- 设置UIImage的边框和圆角大小以及颜色
- 第二章:第四课 css 3.0属性border-radius设置边框圆角
- (iPad/iPhone)给各种控件设置边框或圆角
- CSS+DIV 设置圆角边框加阴影效果
- IOS设置UIView的边框为圆角
- Android给TextView设置透明背景、圆角边框
- (转)#小美化#Android给TextView设置透明背景、圆角边框
- 把主框架窗口设置为圆角矩形,并改变外围边框颜色
- 设置TextInput控件获得焦点时边框的某一角为圆角.
- IOS设置UIView的边框为圆角
- UIView设置圆角、边框和阴影
- 给View设置圆角以及边框
- 设置UIImage或UIView圆角 、设置UIView边框的代码
- 如何用控件的CALayer 的特性创建 圆角界面,边框,和设置背景
- 给UIImageview 添加边框 或者设置成圆角
- 给UIImageview 添加边框 或者设置成圆角