CSS3+SVG 响应式图标设计

除了网页内容、布局需要进行响应式设计之外,有时图标也需要针对不同的屏幕尺寸做出相应的调整。

本文简单介绍一个使用SVG图和CSS3来实现的响应式设计实例。

1. CSS代码,Logo的背景使用了一张svg图片,该图片包含了不同的尺寸的logo元素。

body {
    background: #000;
}
header {
    height: 100vh;
    display: -webkit-flex;
    display: flex;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-align-items: center;
    align-items: center;
    -moz-transition: all, 0.5s;
    -o-transition: all, 0.5s;
    -webkit-transition: all, 0.5s;
    transition: all, 0.5s;
}
.logo {
    margin: 0;
    padding: 0;
    text-indent: -9999em;
    background: url("/uploads/150101/dd-logo.svg") no-repeat;
    background-position: center -500px;
    height: 300px;
    width: 300px;
}
@media only screen and (min-width: 640px) {
    .logo {
        background-position: center -200px;
    }
}
@media only screen and (min-width: 960px) {
    .logo {
        background-position: center 100px;
    }
}
2. html代码

<div class='container'>
    <header>
        <h1 class='logo'>Deloitte Digital</h1>
    </header>
</div>

在线演示地址: http://wow.techbrood.com/fiddle/4302

拖动改变预览屏幕的尺寸即可看到响应式设计的效果。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值