CSS响应式

CSS 响应式设计CSS 响应式设计Viewport设置Viewport网格视图媒体查询窗口小于500px,横屏图片添加图片背景图片背景-简写属性不同设备显示不同的图片HTML 5 picture 元素视频widthmax-width属性Bootstrap自己实现使用bootstrapViewport...
摘要由CSDN通过智能技术生成

CSS 响应式设计

Viewport


  • viewport 是用户网页可视区域

设置Viewport
  • width:控制viewport 大小,可以指定一个值(600px),或特殊的值,如:device-width为设备的宽度
  • height: 高度
  • initial-scale: 初始缩放比例,也就是页面第一次load时候缩放比例
  • maximum-scale: 允许用户缩放到的最大比例
  • minimum-scale: 允许用户缩放到的最小比例
  • user-scalable:用户是否可以手动缩放

网格视图


很多网页是按列来布局的,通常是12列,宽度100%,在浏览器窗口大小调整时自动伸缩。


  • 确保所有的HTML 元素都有box-sizing 属性且设置为border-box

    ​ * {box-sizing: border-box; }

  • 12列网格系统可以更好的控制响应式网页

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
    * {
        box-sizing: border-box;
    }
    .row:after {
        content: "";
        clear: both;
        display: block;
    }
    [class*="col-"] {
        float: left;
        padding: 15px;
    }
    .col-1 {
    width: 8.33%;}
    .col-2 {
    width: 16.66%;}
    .col-3 {
    width: 25%;}
    .col-4 {
    width: 33.33%;}
    .col-5 {
    width: 41.66%;}
    .col-6 {
    width: 50%;}
    .col-7 {
    width: 58.33%;}
    .col-8 {
    width: 66.66%;}
    .col-9 {
    width: 75%;}
    .col-10 {
    width: 83.33%;}
    .col-11 {
    width: 91.66%;}
    .col-12 {
    width: 100%;}

    html {
        font-family: "Lucida Sans", sans-serif;
    }
    .header {
        background-color: #9933cc;
        color: #ffffff;
        padding: 15px;
    }
    .menu ul {
        list-style-type: none;
        margin: 0;
        padding: 0;
    }
    .menu li {
        padding: 8px;
        margin-bottom: 7px;
        background-color :#33b5e5;
        color: #ffffff;
        box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    }
    .menu li:hover {
        background-color: #0099cc;
    }
</style>
</head>
<body>

    <div class="header">
        <h1>Chania</h1>
    </div>

    <div class="row">

        <div class="col-3 menu">
            <ul>
                <li>The Flight</li>
                <li>The City</li>
                <li>The Island</li>
                <li>The Food</li>
            </ul>
        </div>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值