【问题标题】:Make a div appear as though the bottom left and right corners are lifting off the page a little using box shadow?使用盒子阴影使 div 看起来好像左下角和右下角从页面上抬起一点?
【发布时间】:2011-08-07 15:42:00
【问题描述】:

有没有人知道如何做到这一点的教程,或者有没有人有一个小例子?

示例:http://hazelmade.com/projects.html

【问题讨论】:

    标签: shadow css


    【解决方案1】:

    该网站上的阴影是根据这些元素的特定宽度定制的图像。

    如果您想遵循他们所做的类似技术,您可以添加一个绝对位于 div 下方的子图像...

    jsfiddle 示例:http://jsfiddle.net/gbFNk/

    HTML:

    <div id="example">
        content here...
        <img id="shadow" src="http://hazelmade.com/images/drop_shadow.png" />
    </div>
    

    css:

    #example { 
       width:796px; //your tailor made shadow needs to be this long
       height:100px;
       position:relative;
       background:grey;
    }
    
    #shadow {
        position:absolute;
        bottom:-15px; //this is the height of the custom image.
    }
    

    或者,如果您需要像这样具有不同宽度的阴影,您可以制作 2 个阴影(每个角一个)并执行以下操作:

    HTML:

    <div id="example">
        content here...
        <div id="dropshadow">
        <img class="left_shadow" src="leftshadow.png" />
        <img class="right_shadow" src="rightshadow.png" />
        <div style="clear:both"></div>
        </div>
    </div>
    

    css:

    #example { 
       width:796px;
       height:100px;
       position:relative;
       background:grey;
    }
    
    #dropshadow {
        width:796px; //needs to be the same width as the parent div
        position:absolute;
        bottom:-15px; //this still needs to be the height of the custom images.
    }
    
    #dropshadow img.left_shadow {
        float:left;
    }
    #dropshadow img.right_shadow {
        float:right;
    }
    

    【讨论】:

      【解决方案2】:

      CSS drop-shadows without images 演示页面上的“提升角”示例表明,不使用图像也是可能的。它依赖于 CSS3 支持,特别是 box-shadow 和 transform,但这是纯 CSS 解决方案所期望的。

      技术的完整细节可以found in the main article Nicolas Gallagher。

      【讨论】:

      • 很棒的解决方案,但是 css3 使其与旧浏览器不兼容...如果目标市场是较新的浏览器 id,肯定会选择此选项。 +1 :)
      • 旧的浏览器应该被排除在外。目标受众年龄在 60 岁以下。我们不应该迎合 ie6,而是让网站至少具有可读性,并发布一条好消息,告诉他们他们可怕的不安全、丑陋、无功能、糟糕的浏览器,并告诉他们升级到 google chrome :D ie6 用户可以看到和阅读该网站,但他们没有得到任何花哨的东西。
      猜你喜欢
      • 1970-01-01
      • 2021-08-21
      • 1970-01-01
      • 2017-09-19
      • 2013-12-22
      • 1970-01-01
      • 1970-01-01
      • 2016-06-08
      • 1970-01-01
      相关资源
      最近更新 更多