首页 > 其他 > 详细

背景缩放

时间:2017-03-11 13:06:39      阅读:250      评论:0      收藏:0      [点我收藏+]

只有图片可以设置宽度和高度,背景图片可以通过:

background-size:宽度   高度;

技术分享

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css" media="screen">
        /*第一种背景缩放方式*/
        .box1
        {
            width:500px;
            height: 300px;
            background: url(image/背景缩放.jpeg);/*no-repeatb*/
            box-shadow: 1px 1px 1px #333333;
            border:1px solid grey;
            border-radius: 10px;
            background-size: 600px 600px;
            position: relative;
        }
        .txt1
        {
            width: 498px;
            height:50px;
            background:rgba(255,255,255,0.6);
            position: absolute;
            bottom: 0;
        }
        /*第二种背景缩放方式*/
        .box2
        {
            width:500px;
            height: 300px;
            background: url(image/背景缩放.jpeg);
            box-shadow: 1px 1px 1px #333333;
            border:1px solid grey;
            border-radius: 10px;
            background-size: cover;/*常用的方式*/
            position: relative;
        }
        .txt2
        {
            width: 498px;
            height:50px;
            background:rgba(255,255,255,0.6);
            position: absolute;
            bottom: 0;
        }
    </style>
</head>
<body>
    <div class="box1">
        <div class="txt1">实现效果</div>
    </div>
    <div class="box2">
        <div class="txt2">实现效果</div>
    </div>

</body>
</html>

技术分享

 

背景缩放

原文:http://www.cnblogs.com/juansilence/p/6534486.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!