一、元件
  1. 自定义按钮
    可用button或a   display为 inline-block 方便设置格式,通过 padding,height,line-height,font-size设置按钮的大小

     <!DOCTYPE html>
    <html>
    <head>
    <title>BUTTON</title>
    <meta charset="utf-8">
    <style type="text/css">
    a {
    text-decoration: none;
    }
    span{
    display: inline-block;
    border-style: solid;
    border-width: 4px 4px 0;
    border-color: #fff transparent transparent;
    vertical-align: middle;
    margin-left: 3px;
    }
    .u-btn{
    display: inline-block;
    box-sizing: content-box;
    -moz-box-sizing: content-box;
    -webkit-box-sizing: content-box;
    padding: 4px 15px;
    margin: 20px;
    height: 20px;
    line-height: 20px;
    border: 1px solid #2b88bf;
    border-radius: 5px;
    background:linear-gradient(#6dbde4,#399dd8);
    font-size: 12px;
    color: #fff;
    cursor: pointer;
    }
    .u-btn:hover{
    background-color:#122772;
    }
    </style>
    </head>
    <body>
    <button class="u-btn">click</button>
    <a class="u-btn" href="#">click</a>
    <a class="u-btn" href="#">
    click
    <span></span>
    </a>
    </body>
    </html>
  2. 按钮组合
    灵活使用display  inline-block设置下拉列表
     <!DOCTYPE html>
    <html>
    <head>
    <title>按钮组合</title>
    <meta charset='utf-8'>
    <style type="text/css">
    span{
    display: inline-block;
    border-style: solid;
    border-width: 4px 4px 0;
    border-color: #fff transparent transparent;
    vertical-align: middle;
    margin: 0;
    } .u-btns{
    position: relative;
    display: inline-block;
    margin: 20px;
    }
    .u-btn{
    display: inline-block;
    float: left;
    padding: 6px 15px;
    margin: 0px;
    font-size: 12px;
    color: #fff;
    border: 1px solid #2b88bf;
    background:linear-gradient(#6dbde4,#399dd8);
    border-width: 1px 1px 1px 0;
    cursor: pointer;
    }
    button:first-child{
    border-radius: 5px 0 0 5px;
    }
    button:last-child{
    border-radius: 0 5px 5px 0;
    }
    ul{
    position: absolute;
    top: 13px;
    left: auto;
    right: 0px;
    padding: 0;
    display: inline-block;
    list-style-type: none;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    }
    li,a{
    height: 30px;
    line-height: 30px;
    text-decoration: none;
    font-family: Arial;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    }
    a{
    display: block;
    padding: 4px 8px;
    text-align: center;
    }
    li:empty{
    border-top: 1px solid #ddd;
    height: 5px;
    line-height: 5px;
    margin: 0px;
    }
    li:hover{
    background: #f7f7f7;
    }
    </style>
    </head>
    <body>
    <div class="u-btns">
    <button class="u-btn" type="button">click</button>
    <button class="u-btn" type="button">
    <span></span>
    </button>
    <ul>
    <li><a href="#">下拉式菜单项</a></li>
    <li><a href="#">下拉式菜单项</a></li>
    <li><a href="#">下拉式菜单项</a></li>
    <li></li>
    <li><a href="#">下拉式菜单项</a></li>
    </ul>
    </div>
    </body>
    </html>

二、BUG

  1. 问题:如果参照物没有触发haslayout,那么在ie6中“绝对定位的容器”的left和bottom就会有问题

    解决方案:在“相对定位的父容器”上加入 zoom:1 来触发ie的haslayout即可解决

    小技巧:通常我们在设置一个容器为position:relative的时候,都会加上zoom:1来解决很多ie下的问题

  2. 问题:在ie67下,红色区域溢出,拖动垂直或水平滚动条时,红色区域不会动
    解决方案:只需要在有滚动条的容器上也设置相对定位即可。
  3. 问题:IE6下参照物宽高为奇数时,绝对定位元素设置了位置为0或100%时,仍会有1px的空隙
    解决方案:设为偶数
  4. 问题:浮动时margin加倍
    解决:设置为inline

三、布局

  1. 全局自适应

    所有元素绝对定位,上下部固定高度,宽度100%,中间高度auto
    注意合并样式,精简代码

     <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>全局自适应布局</title>
    <style type="text/css">
    div{
    position: absolute;
    left: 0px;
    }
    .hd,.foot{
    width: 100%;
    height: 100px;
    }
    .hd{
    top: 0px;
    background-color: #ccc;
    }
    .con-left,.con-right{
    top: 100px;
    bottom: 100px;
    height: auto;
    }
    .con-left{
    left: 0px;
    width: 300px;
    background-color: #b8d9e0;
    }
    .con-right{
    right: 0px;
    margin-left: 300px;
    background-color: #b8d9aa;
    }
    .foot{
    bottom: 0px;
    background-color: #ccc;
    }
    </style>
    </head>
    <body>
    <div class="hd"></div>
    <div class="con-left"></div>
    <div class="con-right"></div>
    <div class="foot"></div>
    </body>
    </html>
  2. 前自定义后跟随
    定义两层结构,利用magin的负值保持跟随者在尾部的空间
  3. 表头固定内容滚动的表格
    给内容设置最大高度值,超出时使用滚动条
    注意:overflow-y是用来给div进行裁剪的,所以tbody部分需要在div中
    table>head,div(table>tbody)
  4. 纯CSS手风琴
    通过列表显示图片,定义ul固定宽高,定义li

自定义按钮~自适应布局~常见bug的更多相关文章

  1. 常用样式制作思路 自定义按钮~自适应布局~常见bug seajs简记 初学者必知的HTML规范 不容忽略的——CSS规范

    常用样式制作思路   学习常用样式总结参考来自这里 带点文字链接列表利用:before实现 1 <!DOCTYPE html> 2 <html lang="en" ...

  2. Flutter 中的常见的按钮组件 以及自定义按钮组件

    Flutter 里有很多的 Button 组件很多,常见的按钮组件有:RaisedButton.FlatButton. IconButton.OutlineButton.ButtonBar.Float ...

  3. 22Flutter中的常见的按钮组件 以及自定义按钮组件

    /* Flutter中的常见的按钮组件 以及自定义按钮组件 一.Flutter中的按钮组件介绍 Flutter里有很多的Button组件,常见的按钮组件有:RaisedButton/FlatButto ...

  4. 常见css水平自适应布局

    左右布局,左边固定,右边自适应布局 BFC方法解决 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...

  5. css经典布局——头尾固定高度中间高度自适应布局

    转载:穆乙 http://www.cnblogs.com/pigtail/ 相信做过后台管理界面的同学,都非常清楚这个布局.最直观的方式是框架这个我不想多写费话,因为我们的重心不在这里.如果有不了解的 ...

  6. 【转】CSS深入理解流体特性和BFC特性下多栏自适应布局

    这篇文章发布于 2015年02月12日,星期四,23:36,归类于 css相关. 阅读 30873 次, 今日 63 次 by zhangxinxu from http://www.zhangxinx ...

  7. 为iPhone6设计自适应布局

    Apple从iOS6加入了Auto Layout后开始就比较委婉的开始鼓励.建议开发者使用自适应布局,但是到目前为止,我感觉大多数开发者一直在回避这个问题,不管是不是由于历史原因造成的,至少他们在心底 ...

  8. 为iPhone6 设计自适应布局(一)

    译者的话:本文是自适应布局的巩固篇,所以对布局约束的添加操作步骤等没有详细的说明.如果看着吃力的话请先移步Swift自适应布局(Adaptive Layout)教程. Apple从iOS6加入了Aut ...

  9. Swift自适应布局(Adaptive Layout)教程(二)

    给TextContainer中添加内容 打开 Main.storyboard ,从组件库(Object Library)中拖拽两个 Label 组件到TextContainer中,位置可以随意摆放: ...

随机推荐

  1. 如何保存PDF、Word和Excel文件到数据库中

    在项目中,有时候我们很需要把PDF.Word和Excel文档等等上传到数据库,以便日后使用.今天这篇文章向大家讲解如何将这些文件保存到数据库的. 详细步骤 第一步:打开数据库,单击新建查询,创建一个名 ...

  2. 正经学C#_表达式与其运算符[算术运算符]:《c#入门经典》

    表达式:正如字面意义,它是通过算术运算符来进行运算的数学公式.表达式的意义我们都是很明白的,大白话就是一个公式嘛.不是很难懂. 表达式不是一个单独的存在,必然有操作数或者操作符的.在c#中有操作符有很 ...

  3. XAF-BI.Dashboard模块概述 web/win

    Dashboard模块介绍了在ASP.NET XAF 和 WinForms 应用程序中简单的集成 DevExpress Dashboard控件的方法. 其实不仅仅是控件,利用了现有的XAF数据模型,这 ...

  4. JDK1.8源码阅读系列之一:ArrayList

    本篇随笔主要描述的是我阅读 ArrayList 源码期间的对于 ArrayList 的一些实现上的个人理解,有不对的地方,请指出- 先来看一下 ArrayList 的继承图: 由图可以看出,Array ...

  5. Java入门第二季第一章类和对象知识点

    Java 中的 static 使用之静态方法 1. 静态方法中可以直接调用同类中的静态成员,但不能直接调用非静态成员.如: 如果希望在静态方法中调用非静态变量,可以通过创建类的对象,然后通过对象来访问 ...

  6. 链接中的href=#是什么意思呢

    链接当前页面. ------------------- 通常有如下用法: <a href="#" onclick="window.close()"> ...

  7. mysql添加mcafee 审计插件

    插件源码地址https://github.com/mcafee/mysql-audit插件安装方法https://github.com/mcafee/mysql-audit/wiki/Installa ...

  8. trove 开发者阅读翻译

    介绍 Trove为OpenStack提供数据库的服务.它的设计运行完全符合OpenStack,目标是让用户能快速.轻松地利用关系数据库的特点,没有负担的处理复杂的管理任务.云用户和数据库管理员可以根据 ...

  9. RelativeLayout各个属性

    android:layout_above="@id/xxx"  --将控件置于给定ID控件之上 android:layout_below="@id/xxx"  ...

  10. hdu 1848 Fibonacci again and again(简单sg)

    Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F(2)=2;F(n)=F(n-1)+F(n-2 ...