ch4 圆角框
固定宽度的圆角框
只需要两个图像:一个应用于框的顶部,一个应用于底部
<div class="box">
<h2>Lorem Ipsum</h2>
<p class="last">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin venenatis turpis ut quam. In dolor. Nam ultrices nisl sollicitudin sapien. Ut lacinia aliquet ante.<p>
</div>
<style>
.box {
width: 424px; //框的宽度必须与顶部和底部图像的宽度一致
background: url(img/tile2.gif) repeat-y;//在框上设置重复显示的背景图像
}
.box h2 {
background: url(img/top2.gif) no-repeat left top;//顶部图像应用于标题元素
padding-top: 20px;
}
.box .last {
background: url(img/bottom2.gif) no-repeat left bottom;//底部图像应用于文字元素
padding-bottom: 20px;
}
.box h2, .box p {
padding-left: 20px;//设置padding使得内容不碰到框的边界
padding-right: 20px;
}
p {
margin: 0; /* fixes bug in IE */
}
</style>

灵活的圆角框(滑动门技术)
不要使用一个图像组成顶部和底部图像,而是应用两个相互重叠的图像,随之框尺寸的增加,大图像就会有更多部分显露出来,就实现了框扩展的效果------滑动门技术。一个图像在另一个图像上滑动,将它的一部分隐藏了起来,所以需要更多的图像,则必须在标记中添加两个额外的无语义元素。
bottom-left.gif应用于主框div,bottom-right.gif应用于外边的div,top-left.gif应用于内部的div,top-right.gif应用于标题。

<div class="box">
<div class="box-outer">
<div class="box-inner">
<h2>Lorem Ipsum</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin venenatis turpis ut quam. In dolor. Nam ultrices nisl sollicitudin sapien. Ut lacinia aliquet ante.<p>
</div>
</div>
</div>
<style>
.box {
width: 20em;//框的宽度以em为单位,框会随着文本尺寸进行伸缩,也可以设置为%,框就会随着浏览器窗口的尺寸进行伸缩
background: url(img/bottom-left.gif) no-repeat left bottom; //bottom-left.gif应用于主框div
}
.box-outer {
background: url(img/bottom-right.gif) no-repeat right bottom; //bottom-right.gif应用于外边的div
padding-bottom: 1px;
}
.box-inner {
background: url(img/top-left.gif) no-repeat left top; //top-left.gif应用于内部的div
} .box h2 {
background: url(img/top-right.gif) no-repeat right top; //top-right.gif应用于标题
padding-top: 1em;
}
.box h2, .box p {
padding-left: 1em;
padding-right: 1em;
}
</style>

CSS3新特性
- 多个背景图像:不是定义一个背景图像,而是使用任意数量的图像,用background-image定义要使用的所有图像,background-repeat指定是否应该重复显示,用background-position设置它们的位置。
<div class="box">
<h2>My Rounded Corner Box</h2>
<p>This is my rounded corner box. Isn't it spiffing! I think it's the best rounded corner box in the world. I mean, look at those corners. How round are they? Now take a look at the mark-up. That's right, no extraneous div's. Just pure HTML goodness. Sexy huh? I bet you're wondering how I did that? Well it's easy with CSS 3. You simply use multiple background images. </p>
</div>
<style>
.box {
background-image: url(img/mtop-left.gif), url(img/mtop-right.gif), url(img/mbottom-left.gif), url(img/mbottom-right.gif);
background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
background-position: top left, top right, bottom left, bottom right;
}
</style>
- border-radius:设置边框角的半径。
- border-image:允许指定一个图像作为元素的边框,根据一些百分比规则把图像划分为9个单独的部分,浏览器会自动的使用适当的部分作为边框的对应部分---九分法缩放,有助于避免在调整圆角框大小时出现的失真。
<div class="box">
<h2>Yet Another Rounded Corner Box</h2>
<p>This is another rounded corner box......</p>
</div>
.box {
-webkit-border-image: url(img/corners.gif) 25% 25% 25% 25% / 25px round round;
}

在距离框的顶边和底边25%的地方画两条线,在距离左边和右边25%的地方画两条线,框就形成了9个部分。
border-image属性会自动的把图像的每个部分用于对应的边框,因此,图像的左上部分用作左上边框,右边中间部分用作右边的边框。25px是边框的宽度,如果图像不够大,它们会自动平铺,产生一个可扩展的框。
ch4 圆角框的更多相关文章
- 大神写的一个纯CSS圆角框,膜拜!(支持IE9一下的低版本)
留着提醒自己,底层才是最重要的,不要一直傻瓜的编程下去! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&q ...
- CSS圆角框,圆角提示框
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 笔记《精通css》第4章 背景图像,平铺方式,背景定位,圆角框,投影,不透明
第4章 背景图像,平铺方式,背景定位,圆角框,投影,不透明 1.背景图像 background-image:url() 2.平铺方式 background-repeat:repeat-x repea ...
- CSS 圆角框
转载请注明来源:https://www.cnblogs.com/hookjc/ 其实这种圆角框是靠一个个容器堆砌而成的,每一个容器的宽度不同,这个宽度是由margin外边距来实现的,如:margin: ...
- 小程序canvas 圆角框带填充颜色
// ctx: 获取canvas的id --- const ctx = wx.createCanvasContext('canvasId') // x 横坐标 y 纵左边 w 框的宽度 h 框的高 ...
- 兼容ie6/ff/ch/op的div+css实现的圆角框
<!DOCTYPE html> <html> <head> <title>青春不迷茫:寻梦时代的“蚁族”逆袭之旅- 职场管理专题-中国人力资源开发网-中 ...
- 使用Axure RP原型设计实践08,制作圆角文本框
本篇体验做一个简单圆角文本框,做到3个效果: 1.初始状态,圆角文本框有淡淡的背景色,边框的颜色为浅灰色2.点击圆角文本框,让其获取焦点,边框变成蓝色,背景色变成白色3.圆角文本框失去焦点,边框变成红 ...
- DIV+CSS圆角边框
简洁型css圆角: 方法1: 简洁型css圆角矩形 code1: <style type="text/css"> .b1,.b2,.b3,.b4,.b1b,.b2b,. ...
- 44.Android之Shape设置虚线、圆角和渐变学习
Shape在Android中设定各种形状,今天记录下,由于比较简单直接贴代码. Shape子属性简单说明一下: gradient -- 对应颜色渐变. startcolor.endcolor就不多说 ...
随机推荐
- 4_3 救济金发放(UVa133)<子过程/函数设计>
为了缩短领救济品的队伍,NNGLRP决定了以下策略:每天所有来申请救济品的人会被放在一个大圆圈,面朝里面.标明一个人为编号1号,其他的就从那个人开始逆时针开始编号直到N.一个官员一开始逆时针数,数k个 ...
- 用myeclipse快速搭建hibernate实现数据库访问
前言 hibernate使用的大致过程为引入jar包.配置主配置文件.配置映射文件.编写实体类.编写dao.但是每一步都需要知道的内容都相对不少,造成困难.如果使用myeclipse提供的支持将非常容 ...
- java 生成签名文件
如何使用jdk中的keytool.exe生成一个签名文件? 1.通过命令行cmd进入jdk的bin目录下,会发现有一个keytool.exe文件 执行命令:keytool -genkey -alias ...
- 吴裕雄 python 神经网络——TensorFlow 输入文件队列
import tensorflow as tf def _int64_feature(value): return tf.train.Feature(int64_list=tf.train.Int64 ...
- dojo框架笔记
一.模块定义 1.定义只含值对,没有任何依赖的模块(moudle1.js) define({ color: "black", size: "unisize" } ...
- a链接内容过长,换行
上图为溢出情况,此情况均为 英文或数字,但亲测,中文也可正常换行. 添加 word-wrap: break-word; 后,正常换行. 若不希望换行,设为 white-space: nowra ...
- lnmp1.5安装memcache
1.安装libevent 由于Memcache用到了libevent这个库用于Socket的处理,所以需要安装libevent. # wget http://www.monkey.org/~provo ...
- loadrunner回放时弹出windows安全警告
在录制 https://www.baidu.com,回放时总是弹出安全警告. 处理方案:打开IE的internet选项-->隐私,设置成“接受所有Cookie”,如下图所示即可解决
- DVWA靶机-sql自动注入
1. 使用dvwa靶机进行sql注入实战(注:当前靶机安全级别为low) 打开sql漏洞,发现输入不同的数字会返回不同的信息, 先尝试手工判断是否存在sql注入 一般sql注入语句像这样,我们构造的是 ...
- kali apt update 错误——下列签名无效: EXPKEYSIG ED444FF07D8D0BF6 Kali Linux Repository
这是因为key过期了 wget -q -O - https://archive.kali.org/archive-key.asc | apt-key add apt update