gpt4 book ai didi

css - 使用 CSS3 按钮闪耀/发光

转载 作者:行者123 更新时间:2023-12-02 08:56:11 27 4
gpt4 key购买 nike

我有一个导航菜单,我试图仅使用 CSS3 和 HTML 重新创建它。根据所附图片上的“主页”按钮,该设计要求在当前选择的菜单按钮上发光/发光。仅使用代码就可以实现这种效果,还是我需要使用发光图像?! alt text

请注意,亮光和白线在按钮中心最明显,然后向边缘逐渐消失。

最佳答案

CSS3 的 radial gradients让您实现类似的效果,尽管使用 CSS 背景图像可能更容易进行像素完美调整。具体来说,CSS3 的渐变是线性的,甚至是径向渐变。

我已经使用 Firefox 的径向渐变构建了一个小示例(支持 Webkit 需要完全不同的代码):http://jsfiddle.net/rxMf6/

Example of button with radial gradient

HTML:

<div class="highlighted-button">
<div class="highlight"></div>
Button
</div>

CSS:

.highlighted-button {
background: #000;
color: #fff;
font: bold 0.8em Arial, sans-serif;
padding-bottom: 0.9em;
text-align: center;
text-transform: uppercase;
width: 8em;
}

.highlight {
background: -moz-radial-gradient(center top, ellipse farthest-side,
#fff 0%, #000 100%);
height: 0.5em;
margin-bottom: 0.4em;
}

关于css - 使用 CSS3 按钮闪耀/发光,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4709215/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com