Html 有可能在背景中画一个带箭头和渐变的圆吗?
我需要画一个带箭头和渐变的圆圈。我知道我可以用它作为图像。但它需要在屏幕上灵活调整大小,以便背景梯度将动态变化。我很好奇是否可以使用单个Html 有可能在背景中画一个带箭头和渐变的圆吗?,html,css,Html,Css,我需要画一个带箭头和渐变的圆圈。我知道我可以用它作为图像。但它需要在屏幕上灵活调整大小,以便背景梯度将动态变化。我很好奇是否可以使用单个标记和CSS来实现这一点 是的,在CSS3中可以使用边框图像编辑: 下面是一个使用两个div使用旋转和边界半径模拟箭头的示例: 旧帖子: 以下是唯一可能的(AFAIK)css箭头示例: HTML: 类似这样的东西 就像你说的那样 <a class="link" href="#"> <span>Link</span>
标记和CSS来实现这一点
是的,在CSS3中可以使用
边框图像编辑:
下面是一个使用两个div使用旋转和边界半径模拟箭头的示例:
旧帖子:
以下是唯一可能的(AFAIK)css箭头示例:
HTML:
类似这样的东西
就像你说的那样
<a class="link" href="#">
<span>Link</span>
</a>
我很确定它是跨浏览器的,但我不确定边框图像
。您可以使用@roXon的代码,创建第二个跨距,然后将其定位到文本的右侧。这只是使用一个图像。输出:
尝试使用不同的字体或unicode字符来获得箭头的外观
例如:
标记:
<span></span>
这里有一个想法。它将需要一些调整取决于你需要什么
颜色、大小等都可以根据您的需要进行调整
是最简单、最明显的箭头。但这不是唯一的选择。维基百科列表。您必须在Windows(7?)上使用默认字体交叉引用它们 您介意使用的不仅仅是
?
和
怎么样?@Charlie-它实际上是一个链接,所以我想这个标记可能是可能的,我从来没有很好地处理过边框图像,你要求它是W3C有效的吗?@Charlie-没有必要,但应该在IE9中兼容。我在这里创建了IE9兼容的渐变,如果您对旧浏览器不具备这些功能感到满意,那么您当然可以使用边界半径
创建圆角,使用背景:线性渐变
创建渐变。但是如果没有图像或SVG,您将无法复制阴影、浮雕、渐变填充的
形状;我喜欢简单。您可能需要执行边界半径:50%代码>--这将使更改大小更容易。还有更多的规则,但它们只涉及少数浏览器。编辑:如果你想改变这一点,并记下Unicode符号,我可以删除我的答案。它们已经涵盖了很多相同的领域。是的,我个人使用的边界半径除了px
之外,从未使用过任何东西,使用em
似乎很奇怪(可能不完全支持),但至少它似乎调整到了字体大小。哦,等等,你是说-moz边界半径
之类的,是的,我忘了。标准border radius
支持现在似乎好多了,但渐变仍然是一个难题-我刚刚复制了演示中的输出。你可以使用Madmartigan的代码而不是roXon的代码作为第二跨度。如果您不介意使用图像,您可以将其替换为op中的图像,@JitendraVyas:您始终可以将图像与背景大小
结合使用。如果你一定要让它看起来完美,这是唯一的方法。这里有一个例子,使用
作为箭头,使用下面的注释者代码,还有,放置字体系列:georgia
似乎使
看起来更漂亮。
.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 */
}
<a class="link" href="#">
<span>Link</span>
</a>
.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;
}
<span></span>
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;
}
.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 */
}