按钮渐变边框
- inset inset 为简写属性,对应于 top、right、bottom 和 left 属性。其与 margin 简写属性具有相同的多值语法
INFO
inset 也可以居中
inset 居中
查看代码
vue
<template>
<div class="parent">
<div class="child"></div>
</div>
</template>
<style lang="less" scoped>
.parent {
position: relative;
height: 300px;
.child {
width: 50px;
height: 50px;
background-color: violet;
position: absolute;
inset: 0;
margin: auto;
}
}
</style>translate 居中
查看代码
vue
<template>
<div class="parent">
<div class="child"></div>
</div>
</template>
<style lang="less" scoped>
.parent {
position: relative;
height: 300px;
.child {
width: 50px;
height: 50px;
background-color: violet;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
}
</style>