zoukankan      html  css  js  c++  java
  • 投影

    使用css可以给投影效果很大的灵活性。

    简单的css投影:

    原理是将一个大的背景图像应用于容器div的背景,然后使用负边距偏移这个图像,从而显示出投影。

            <style>
                .img-wrapper{
                    background: url(img/shadow.gif) no-repeat bottom right;
                    clear: right;
                    float: left;    //因为div是块级元素,背景的投影图会水平伸展,占据所有空间,而我们需要div包围图像,可以显示的设置div的宽度,但这样会限制这种技术的用途
                      //可以浮动div,让它收缩包围的效果。ie5.x不支持,可以对ie5隐藏样式。
                    position: relative; //为了兼容ie6
                }
                .img-wrapper img{
                    margin: 5px 5px 0px -5px;
                    background: #fff;
                    border: 1px solid #a9a9a9;
                    padding: 4px;
                    display: block;        //这两个属性为了兼容ie6
                    position: relative;    //同上
                }
            </style>
        </head>
        <body>
            <div class="img-wrapper">
                <img src="img/dunstan.jpg" width="300px" height="300px" />
            </div>
        </body>

    来自Clagnut的投影方法:

    不使用外边距,使用相对定位来偏移图像。

                .img-wrapper{
                    background: url(img/shadow.gif) no-repeat bottom right;
                    float: left;
                    line-height: 0;
                }
                .img-wrapper img{
                    background: #fff;
                    border: 1px solid #a9a9a9;
                    padding: 4px;
                    position: relative;
                    left: -5px;
                    top: -5px;
                }

    box-shadow:需要四个值,垂直水平偏移,投影的宽度,颜色

                .img-wrapper{
                    -webkit-box-shadow: 3px 3px 6px #666;
                    -moz-box-shadow:3px 3px 6px #666;
                    box-shadow: 3px 3px 6px #666;
                }

                .img-wrapper{
                    background: url(img/shadow.gif) no-repeat bottom right;
                    float: left;
                    line-height: 0;
                }
                .img-wrapper img{
                    background: #fff;
                    border: 1px solid #a9a9a9;
                    padding: 4px;
                    position: relative;
                    left: -5px;
                    top: -5px;
                }

  • 相关阅读:
    解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'informat
    安装KubeSphere
    kubesphere 安装
    正则表达式在线测试
    爬虫与Python:(二)Python基础篇——扩展:实现九九乘法表
    为什么 Python 的 Range 要设计成左开右闭区间?
    Python内置函数之range()
    爬虫与Python:(二)Python基础篇——13.类
    爬虫与Python:(二)Python基础篇——12.函数
    CSS之text-align
  • 原文地址:https://www.cnblogs.com/by-dxm/p/6118446.html
Copyright © 2011-2022 走看看