所有這些都可以在CSS 3中完成,但我不會推薦它。如果您希望它在所有瀏覽器中看起來都一樣,那麼使用按鈕和標題的圖像是最好的辦法。如果你想這樣做的CSS反正試試這個:
HTML:
<header>
<div class="shadow"></div>
<h1>Taffies Cupcakes</h1>
<h2><div class="line"></div>Fresh and tasty<div class="line"></div></h2>
</header>
CSS:
header > .shadow {
width: 0px;
height: 0px;
margin: 0px 50%;
box-shadow: 0px 0px 200px 100px white;
}
header h2 > .line {
height: 1px;
width: 100px;
margin: 5px 20px;
background-color: #846a5f;
display: inline-block;
vertical-align: middle;
}
至於其他的答案也提到,radial-gradient
可能是去這裏的路。只要將它應用到header
元素上,而不是使用我的版本和box-shadow(對某些人來說可能有些不好意思)。
更新按鈕:
HTML:
<button class="special"><div class="icon"></div><div class="headline">ORDER NOW</div><div class="description">We deliver in 24 hours</div></button>
CSS:
button.special {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #784f3d), color-stop(1, #846a5f));
background:-moz-linear-gradient(center top, #784f3d 5%, #846a5f 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#784f3d', endColorstr='#846a5f');
background-color:#784f3d;
color: #e7d2c9;
text-align: left;
border: 0;
outline: 0;
border-radius: 5px;
height: 42px;
}
button.special > .icon {
width: 27px;
height: 27px;
/*background-image: url('triangle-button.png')*/
position: absolute;
margin: 5px;
}
button.special > .headline {
margin-left: 42px;
font-size: 18px;
}
button.special > .description {
margin-left: 42px;
font-size: 12px;
}
http://jsfiddle.net/ezdr3xdg/17/
按照您的問題順序:使用CSS漸變/是/是/使用圖像作爲img src或背景。現在你已經足夠了解並告訴我們你是如何做到的 – Devin 2014-09-05 21:07:58