【问题标题】:linear gradient div using CSS3使用 CSS3 的线性渐变 div
【发布时间】:2013-03-14 12:23:25
【问题描述】:

请帮助我如何使用 css 制作 div,如下图所示。

这是我到目前为止的代码... http://jsfiddle.net/L8FfE/

<table class="screenheader" cellspacing="0" cellpadding="0" width="100%" style="padding-top: 5px;">
    <tr style="font-family: Calibri, Arial, Sans-Serif; font-size: 40pt; font-weight: bold;
    color: #fff; background: repeating-linear-gradient(180deg, #23538A , #A7CFDF 5px, #23538A  5px, #A7CFDF 10px);">
        <td width="100%" style="padding-bottom: 5px;">
            <div id="meetingname" width="100%" style="padding-left: 20px; text-align: left;">
                HI Test
            </div>
        </td>
        <td width="100%" style="padding-left: 20px; text-align: left;">
        </td>
    </tr>
</table>

【问题讨论】:

  • 你可以内联添加图片,你应该把你的标记放在问题中。
  • 我有 1 名声望,所以我不能放图片。请帮我设计像我的形象一样的 div
  • 你得到的那是一些可怕的老式学校代码。

标签: html css linear-gradients


【解决方案1】:

这是你的意思吗(除了颜色,我看不懂)?
http://jsfiddle.net/L8FfE/2/

HTML:

<div id="background">
    <div id="overlay"></div>
</div>

CSS:

div#background {
    width: 100%;
    height: 50px;
    background: -webkit-gradient(linear, 0 0, 0 100%, from(#053F63), to(#105C97));
    background: -webkit-linear-gradient(#053F63 0%, #105C97 100%);
    background: -moz-linear-gradient(#053F63 0%, #105C97 100%);
    background: -o-linear-gradient(#053F63 0%, #105C97 100%);
    background: linear-gradient(#053F63 0%, #105C97 100%);
}
div#overlay {
    font-family: Calibri, Arial, Sans-Serif;
    font-size: 40pt;
    font-weight: bold;
    color: #fff;
    width: 100%;
    height: 50px;
    background:    -moz-repeating-linear-gradient(rgba(35, 83, 138, 1) 5px, rgba(167, 207, 223, 0) 5px, rgba(35, 83, 138, 1) 5px, rgba(167, 207, 223, 0) 10px);
    background: -webkit-repeating-linear-gradient(rgba(35, 83, 138, 1) 5px, rgba(167, 207, 223, 0) 5px, rgba(35, 83, 138, 1) 5px, rgba(167, 207, 223, 0) 10px);
    background:         repeating-linear-gradient(rgba(35, 83, 138, 1) 5px, rgba(167, 207, 223, 0) 5px, rgba(35, 83, 138, 1) 5px, rgba(167, 207, 223, 0) 10px);
    -webkit-mask-image: -webkit-gradient(linear, 0 0, 100% 0, from(rgba(0, 0, 0, 0)), color-stop(0.4, rgba(0, 0, 0, 0)), color-stop(0.6, rgba(0, 0, 0, 1)), to(rgba(0, 0, 0, 1)));
    -webkit-mask-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 1) 60%, rgba(0, 0, 0, 1) 100%);
            mask-image:    -moz-linear-gradient(left, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 1) 60%, rgba(0, 0, 0, 1) 100%);
            mask-image:      -o-linear-gradient(left, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 1) 60%, rgba(0, 0, 0, 1) 100%);
            mask-image:         linear-gradient(left, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 1) 60%, rgba(0, 0, 0, 1) 100%);
}

【讨论】:

    【解决方案2】:

    这不太对。您需要另一个 div 来实现左侧渐变和垂直渐变。我只为 Chrome 编写了这个,您还必须将#colors 更改为 rgba,但您可以看到 in the JS fiddle here 它看起来更像 jpeg。

    HTML

    <div class="rightGradient">
        <div class="horizontal stripes"></div>
        <div class="topGradient"></div>
    </div>
    

    CSS

    .stripes {
        position: relative;
        height: 100px;
        width: 375px;
        -webkit-background-size: 100% 6px;
    }
    
    .horizontal {
        background-color: transparent;
        background-image: -webkit-linear-gradient(top, #0f5b97 50%, transparent 50%, transparent);
    }
    
    .rightGradient {
        position: absolute;
        height: 100px;
        width: 375px;
        background-image: -webkit-linear-gradient(right, #074166  20%, #0f5b97 70%);
    }
    
    .topGradient {
        position: absolute;
        top: 0px;
        height: 100px;
        width: 375px;
        background-color: transparent;
        background-image: -webkit-linear-gradient(286deg , #074166 -20%, transparent 70%);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-21
      • 2011-11-24
      • 1970-01-01
      相关资源
      最近更新 更多