我需要制作一个带箭头和渐变的圆圈。我知道我可以用它作为图像。但它需要灵活调整屏幕大小,以便背景渐变动态变化。我很好奇是否可以使用单个<span>
标记和CSS来执行此操作。
答案 0 :(得分:7)
修改强>
下面是一个使用两个div来使用rotation和border-radius模拟箭头的示例:
.btn{
cursor:pointer;
position:relative;
font-family:'Trebuchet MS', Verdana, Arial, sans-serif;
display:inline-block;
padding:3px 0 3px 16px;
text-align:center;
height:22px;
color:#696969;/*#DB7DB4;*/
text-shadow:0px 1px 1px #fff;
-webkit-border-radius: 22px;
-moz-border-radius: 22px;
border-radius: 22px;
border:1px solid rgba(220,87,166,0.8);
box-shadow: 0px 0px 0px 3px rgba(220,87,166, 0.8);
background: #fafafa; /* Old browsers */
background: -moz-linear-gradient(top, #fafafa 0%, #939393 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fafafa), color-stop(100%,#939393)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #fafafa 0%,#939393 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #fafafa 0%,#939393 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #fafafa 0%,#939393 100%); /* IE10+ */
background: linear-gradient(top, #fafafa 0%,#939393 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fafafa', endColorstr='#939393',GradientType=0 ); /* IE6-9 */
}
.btn_circle{
position:relative;
float:right;
margin:0px 3px 0 8px;
display:table;
width:20px;
height:21px;
border:1px solid rgba(255,255,255,0.6);
border-radius:21px;
box-shadow: inset 0px 3px 2px rgb(92, 38, 70);
background: #6b294f; /* Old browsers */
background: -moz-linear-gradient(top, #6b294f 0%, #BE609E 99%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6b294f), color-stop(99%,#BE609E)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #6b294f 0%,#aa6592 99%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #6b294f 0%,#BE609E 99%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #6b294f 0%,#BE609E 99%); /* IE10+ */
background: linear-gradient(top, #6b294f 0%,#BE609E 99%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6b294f', endColorstr='#aa6592',GradientType=0 ); /* IE6-9 */
}
.btn_arr{
position:absolute;
right:8px;
height:3px;
width:10px;
background:#d9d9d9;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
box-shadow:-1px 0px 1px #6F375D;
}
.btn_top{
top:11px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
}
.btn_bot{
top:16px;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
transform: rotate(-45deg);
}
旧帖子:
以下是唯一可能的(AFAIK)css箭头示例:
HTML:
<div class="circle">
<div class="arrow"></div>
</div>
CSS:
.arrow{
margin:0 auto;
width: 0;
height: 0;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
border-left: 8px solid #CFC5CD;
}
.circle{
display:table;
line-height:30px;
width:10px;
height:10px;
padding:3px 5px 3px 7px;
border:2px solid #CFC5CD;
border-radius:21px;
background: #6b294f; /* Old browsers */
background: -moz-linear-gradient(top, #6b294f 0%, #aa6592 99%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6b294f), color-stop(99%,#aa6592)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #6b294f 0%,#aa6592 99%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #6b294f 0%,#aa6592 99%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #6b294f 0%,#aa6592 99%); /* IE10+ */
background: linear-gradient(top, #6b294f 0%,#aa6592 99%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6b294f', endColorstr='#aa6592',GradientType=0 ); /* IE6-9 */
}
答案 1 :(得分:2)
有些事情,
http://jsfiddle.net/charlescarver/kuGSw/
它所使用的只是,就像你说的那样,
<a class="link" href="#">
<span>Link</span>
</a>
然后css看起来像这样,
.link{
background: rgb(255,255,255); /* Old browsers */
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(148,146,149,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(148,146,149,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(148,146,149,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(148,146,149,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(148,146,149,1) 100%); /* IE10+ */
background: linear-gradient(top, rgba(255,255,255,1) 0%,rgba(148,146,149,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#949295',GradientType=0 ); /* IE6-9 */
padding:10px 15px;
border-radius:10px;
box-shadow:inset 0 -1px 0 #935E7A;
border-width: 0px 33px 0px 0px;
-moz-border-image: url(http://i.imgur.com/Eepyg.png) 0 33 0 33 stretch;
-webkit-border-image: url(http://i.imgur.com/Eepyg.png) 0 33 0 33 stretch;
-o-border-image: url(http://i.imgur.com/Eepyg.png) 0 33 0 33 stretch;
border-image: url(http://i.imgur.com/Eepyg.png) 0 33 0 33 stretch;
}
a{
text-decoration:none;
color:#935E7A;
}
我很确定它是跨浏览器,我不确定border-image
。您可以使用@ roXon的代码并进行第二次跨度,然后将其放置在文本的右侧。这只是使用图像。
答案 2 :(得分:2)
输出:
尝试不同的字体或unicode字符,以便按照您希望的方式获取箭头。
标记:
<span></span>
CSS:
span {
/* Base size, adjustable */
font-size:20px;
display:block;
border-radius: 4em;
padding:1em;
width:1em;
height:1em;
color:#fff;
text-shadow:0 0 .25em #000;
background: #60224b;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#60224b), to(#c45e9f));
background: -webkit-linear-gradient(#60224b, #c45e9f);
background: -moz-linear-gradient(#60224b, #c45e9f);
background: -ms-linear-gradient(#60224b, #c45e9f);
background: -o-linear-gradient(#60224b, #c45e9f);
background: linear-gradient(#60224b, #c45e9f);
border:.1em solid #ccc;
}
span:after {
content:">";
font-size:2.5em;
position:relative;
/* A little adjustment */
top:-.4em;
font-weight:900;
}
答案 3 :(得分:1)
这是一个想法。根据你的需要,它需要一些调整。
.awesome {
width: 50px;
height: 50px;
display: inline-block;
text-align: center;
font-weight: bold;
font-size: 40px;
color: white;
background-color: #444444; /* Gradients + Compat */
border-radius: 50%; /* + Compat */
}
颜色,尺码等都可以根据您的需要完成。
&gt; 是最简单,最明显的箭头。它不是唯一的选择。维基百科列出many more Unicode arrows。您必须在Windows上使用默认字体交叉引用它们(7?)。
答案 4 :(得分:0)
是的,在CSS3中可以使用border-image
。