一、素材

  

 

 

 

 

  

二、效果

三、CSS

*{padding:0;margin:0}

/*----------------------------------- 自适应宽度图片按钮 ---------------------------------------*/
.button {
display:inline-block;
} .button span
{
display: inline-block;
height: 47px;
padding: 0px 0px 0px 32px;
background: url(Images/button-left.png) no-repeat 0px 0px;
font: bold 12px/21px 宋体, Arial, Helvetica, sans-serif;
text-align: center;
color: rgb(132, 104, 142);
white-space: nowrap;
}
.button span span {
height: 37px;
padding: 10px 32px 0px 0px;
background: url(Images/button-right.png) no-repeat scroll 100% 0px transparent;
} .pink span {background:transparent url(Images/pink-left.png) 0 0 no-repeat;}
.pink span span {background:transparent url(Images/pink-right.png) 100% 0 no-repeat;} .yellow span {background:transparent url(Images/yellow-left.png) 0 0 no-repeat;}
.yellow span span {background:transparent url(Images/yellow-right.png) 100% 0 no-repeat;} .blue span {background:transparent url(Images/blue-left.png) 0 0 no-repeat;}
.blue span span {background:transparent url(Images/blue-right.png) 100% 0 no-repeat;} .green span {background:transparent url(Images/green-left.png) 0 0 no-repeat;}
.green span span {background:transparent url(Images/green-right.png) 100% 0 no-repeat;} .red span {background:transparent url(Images/red-left.png) 0 0 no-repeat;}
.red span span {background:transparent url(Images/red-right.png) 100% 0 no-repeat;} .imgButton
{
border:0 none;
}

四、HTML

<div>
<a href="#" class="button"><span><span>按钮</span></span></a>
<a href="#" class="button blue"><span><span>图片按钮</span></span></a>
<a href="#" class="button green"><span><span>自适应宽度的图片按钮</span></span></a>
<a href="#" class="button pink"><span><span>自适应宽度的多色彩图片按钮</span></span></a>
<a href="#" class="button yellow"><span><span>自适应宽度的多色彩CSS图片按钮</span></span></a>
<a href="#" class="button red"><span><span>漂亮的自适应宽度的多色彩CSS图片按钮</span></span></a>
</div>
<div>
<button type="button" class="button yellow imgButton"><span><span>按钮</span></span></button>
<button type="button" class="button pink imgButton"><span><span>图片按钮</span></span></button>
<button type="button" class="button blue imgButton"><span><span>自适应宽度的图片按钮</span></span></button>
<button type="button" class="button green imgButton"><span><span>自适应宽度的多色彩图片按钮</span></span></button>
<button type="button" class="button red imgButton"><span><span>自适应宽度的多色彩CSS图片按钮</span></span></button>
<button type="button" class="button imgButton"><span><span>漂亮的自适应宽度的多色彩CSS图片按钮</span></span></button>
</div>

五、说明

一、素材是从一个按钮图片一切为二的,左边图片是32*47,右边图片是300*47,所以,这个图片按钮,最短可为64px,最长可为332px;

二、制作的关键是HTML中文字由两个<span>标签包围,外面的span背景为图片左侧,里面的span背景为图片右侧。

												

漂亮的自适应宽度的多色彩CSS图片按钮的更多相关文章

  1. ASP.NET实例——漂亮的自适应宽度的导航条(仿Discuz!)

    PHP比较成熟的开放的源代码比较多,比方说PrestaShop,比方说Discuz!...... 虽然语言不同,但基本原理是一样的,有时间的话读一读,对学习ASP.NET应该是非常有好处的(唉,什么时 ...

  2. 从三栏自适应宽度布局到css布局的讨论

    如何实现一个三栏自适应布局,左右各100px,中间随着浏览器宽度自适应? 第一个想到的是使用table布局,设置table的宽度为100%,三个td,第1个和第3个固定宽度为100px,那么中间那个就 ...

  3. CSS 圣杯布局升级版---多个固定宽度一个自适应宽度

    1.一个div固定,一个div自适应宽度.两种情况,固定在左或者在右. HTML: <div class="box1"> <div class="mai ...

  4. 纯CSS实现Div高度根据自适应宽度(百分百调整)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  5. CSS布局——左定宽度右自适应宽度并且等高布局

    方法一: 别的不多说,直接上代码,或者参考在线DEMO,下面所有的DEMO都有HTML和CSS代码,感兴趣的同学自己慢慢看吧. HTML Markup <div id="contain ...

  6. css布局:左边固定宽度,右边自适应宽度或右侧固定,左侧自适应三种方法

    方法一:浮动布局 这种方法我采用的是左边浮动,右边加上一个margin-left值,让他实现左边固定,右边自适应的布局效果 HTML Markup <div id="left" ...

  7. css判断不同分辨率显示不同宽度布局实现自适应宽度

    一.CSS DIV网页布局中当分辨率小于等于1024px(像素)时,DIV布局对象显示1000px宽度,当分辨率大于1024px时候显示1200px宽度等需求.使用CSS实现改变浏览器显示宽度从而实现 ...

  8. 简单jQuery图片自适应宽度插件jQuery.imgAutoSize.js

    (function ($) {       var loadImg = function (url, fn) {         var img = new Image();         img. ...

  9. JS实现自适应宽度的Tag切换

    效果体验:http://hovertree.com/texiao/js/3.htm 该效果使用纯JavaScript代码,实现TAB页切换效果,TAB标签根据内容自适应宽度,点击TAB标签切换内容页. ...

随机推荐

  1. Android之旅 笔记总结(一)

    一.Android入门 1.          Android操作系统的体系结构分为4层,由上而下依次是应用程序.应用程序框架.核心类库(包括Android运行时环境)和Linux内核. 2.     ...

  2. Mac配置JAVA_HOME

    首先打开终端,输入/usr/libexec/java_home,看到 /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home 说 ...

  3. Objc基础学习记录2

    1.[类 方法名]; //类方法,-静态成员函数, + (void)fun; 2.[对象名 方法名]; //实例方法, -非静态成员函数, - (void) fun; 3.带有冒号必须要有参数; 4. ...

  4. ANSI_NULLS 和 QUOTED_IDENTIFIER

    1  ANSI_NULLS 当 SET ANSI_NULLS 为 ON 时,对空值进行等于 (=) 或不等于 (<>) 比较时取值为 FALSE    例如:SELECT * from t ...

  5. 【转】Android -- Looper.prepare()和Looper.loop()

    Looper.prepare()和Looper.loop() 原文地址:http://blog.csdn.net/heng615975867/article/details/9194219 Andro ...

  6. Flex SuperTabNavigator Tab标签图片不显示或图片显示不完全

    <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...

  7. MySQL中ON DUPLICATE KEY UPDATE使用

    今天做推断插入用到了MySQL中ON DUPLICATE KEY UPDATE,如今Mark下面! 假设你想做到数据库中没有数据的话插入数据.有数据的话更新数据,那么你能够选择ON DUPLICATE ...

  8. Codeforces Round #338 (Div. 2) C. Running Track dp

    C. Running Track 题目连接: http://www.codeforces.com/contest/615/problem/C Description A boy named Ayrat ...

  9. cdoj 24 8球胜负(eight) 水题

    8球胜负(eight) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/24 ...

  10. Codeforces Beta Round #75 (Div. 1 Only) B. Queue 线段树+二分

    B. Queue Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 codeforces.com/problemset/problem/91/B Descrip ...