简体   繁体   English

如何在导航周围创建径向渐变?

[英]How to create a radial gradient around navigation?

在此处输入图片说明

See the radial gradient flowing around the center of the navigation? 看到围绕导航中心流动的径向渐变吗? Lets suppose I made a div that is the navigation. 假设我做了一个div作为导航。 How would I create a gradient that looks like in the picture? 如何创建图片中的渐变色?

Note: Look at the background behind the menu. 注意:请查看菜单后面的背景。

If you talk about the lighter brown glow that is behind the navigation you can do this with CSS3...: http://jsfiddle.net/Jg8ZC/ 如果您谈论的是导航背后的浅褐色光芒,则可以使用CSS3 ...: http : //jsfiddle.net/Jg8ZC/

  background: #45392d;
  background-repeat: no-repeat;
  background-image: -webkit-radial-gradient(center center, circle contain, #624a36 0%, #45392d 80%); /* New WebKit syntax */  
  background-image: -moz-radial-gradient(center center, circle contain, #624a36 0%, #45392d 80%);  /* Firefox */  
  background-image: -ms-radial-gradient(center center, circle contain, #624a36 0%, #45392d 80%); /* IE10+ */  
  background-image: -o-radial-gradient(center center, circle contain, #624a36 0%, #45392d 80%); /* Opera (13?) */  
  background-image: radial-gradient(center center, circle contain, #624a36 0%, #45392d 80%; /* standard syntax */

This way it will work in every modern browser. 这样,它将在所有现代浏览器中运行。

This is not a radial gradient. 这不是径向渐变。 It seems to be a graphic. 它似乎是一个图形。

As for CSS, Look her http://www.the-art-of-web.com/css/radial-gradients/ or in google. 至于CSS,请查看她的http://www.the-art-of-web.com/css/radial-gradients/或在google中。 Theres plenty of resources out there 那里有很多资源

Here is a editor http://www.westciv.com/tools/radialgradients/index.html 这是一个编辑器http://www.westciv.com/tools/radialgradients/index.html

Example

If you want to do this with CSS, you could use a radial gradient : 如果要使用CSS进行此操作,可以使用径向渐变

background-image: -webkit-radial-gradient(contain, #bf8230 0%, #a65f00 100px);

Example (jsFiddle). 示例 (jsFiddle)。

The above will create a circular glow with a radius of 100px centered in the padding-box of the <div> . 上面的代码将在<div>的padding-box中创建一个半径为100px的圆形发光。

If you want to make a glow "around" an element, you could nest an element with a semitransparent gradient background inside one with a solid background, as in this example . 如果要在元素周围“发光”,可以将具有半透明渐变背景的元素嵌套在具有纯色背景的元素内,如本例所示 You'd have to make sure that the nested element doesn't fill its container, and that its padding box can include the entire glow, or it will appear "cut off". 您必须确保嵌套元素没有填充其容器,并且其填充框可以包含整个发光,否则它将显示为“ cut off”。

(The example was only done for Chrome Beta, and will probably require appropriate vendor prefix incantations and testing for other browsers.) (该示例仅针对Chrome Beta才完成,可能需要适当的供应商前缀提示并针对其他浏览器进行测试。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM