通过一些小研究,我发现可以使用剪辑路径完成制作圆形按钮和色块,但我仍然不理解这个概念。
user6133722
问问题
284 次
1 回答
1
Nativescript 只使用 Web 技术,因此您应该使用 HTML 来实现功能,使用 css 来进行样式设置,所以对于六边形的提交按钮,这个怎么样:
选项1
.hexagon {
position: relative;
width: 90px;
height: 51.96px;
background-color: #64C7CC;
margin: 25.98px 0;
}
.hexagon:before,
.hexagon:after {
content: "";
position: absolute;
width: 0;
border-left: 45px solid transparent;
border-right: 45px solid transparent;
}
.hexagon:before {
bottom: 100%;
border-bottom: 25.98px solid #64C7CC;
}
.hexagon:after {
top: 100%;
width: 0;
border-top: 25.98px solid #64C7CC;
}
<div class="hexagon"></div>
选项 2
您可以只使用 Unicode 字符,例如
<span style="color: #6C6; font-size: 135px;">⬢</span>
然后使用其中任何一个覆盖您的锚标签、按钮、输入等与您想要的文本。第一个解决方案的优点是它不会干扰您的字体选择并且更广泛地兼容,但是,第二个更整洁。
如果您需要更多样式选项,可以在第一个选项中使用图像作为背景。有关自定义选项的更多详细信息,请参见此处。
使用 css 设置圆形样式的类似方法是最好的。通常,您将圆角设置为等于元素宽度一半的半径。
选项 3
/* General Button Style */
.button {
position: relative;
display: block;
background: transparent;
width: 300px;
height: 80px;
line-height: 80px;
text-align: center;
font-size: 20px;
text-decoration: none;
text-transform: uppercase;
color: #e04e5e;
margin: 40px auto;
font-family: Helvetica, Arial, sans-serif;
box-sizing: border-box;
}
.button:before,
.button:after {
position: absolute;
content: '';
width: 300px;
left: 0px;
height: 34px;
z-index: -1;
}
.button:before {
transform: perspective(15px) rotateX(3deg);
}
.button:after {
top: 40px;
transform: perspective(15px) rotateX(-3deg);
}
/* Button Border Style */
.button.border:before,
.button.border:after {
border: 4px solid #e04e5e;
}
.button.border:before {
border-bottom: none; /* to prevent the border-line showing up in the middle of the shape */
}
.button.border:after {
border-top: none; /* to prevent the border-line showing up in the middle of the shape */
}
/* Button hover styles */
.button.border:hover:before,
.button.border:hover:after {
background: #e04e5e;
}
.button.border:hover {
color: #fff;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<a href="#" class="button ribbon-outset border">Click me!</a>
当您开始搜索网络解决方案时,您会发现获得答案要容易得多,例如,感谢最终片段的这个答案。
于 2016-08-22T15:20:33.040 回答