:befor、:after是CSS的伪元素,什么是伪元素呢?伪元素用于向某些选择器设置特殊效果。

我们用CSS手册可以查询到其基本的用法:

  • E:before/E::before 设置在对象前(依据对象树的逻辑结构)发生的内容。用来和content属性一起使用
  • E:after/E::after 设置在对象后(依据对象树的逻辑结构)发生的内容。用来和content属性一起使用
  • Ie6-7 不支持
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>css_brfor_after</title>
<style type="text/css">
body {
width: 300px;
height: auto;
display: block;
margin: 0px auto;
padding: 0px;
text-align: left;
text-decoration: none;
background: #efeeea;
background: linear-gradient(#f9f9f9, #cecbc4);
background: -moz-linear-gradient(#f9f9f9, #cecbc4);
background: -webkit-linear-gradient(#f9f9f9, #cecbc4);
background: -o-linear-gradient(#f9f9f9, #cecbc4);
} #box {
width: 300px;
height: 300px;
} #box .relative {
width: 288px;
height: 288px;
margin-left: 5px;
margin-top: 5px;
background-color: transparent;
border-radius: 5px;
-moz-border-radius: 5px;
border: 2px solid red;
position: absolute;
} #box .relative:before {
width: 288px;
height: 248px;
background-color: transparent;
border-left: 2px solid #fff;
border-right: 2px solid #fff;
position: absolute;
content: '';
left: -2px;
top: 20px;
} #box .relative:after {
width: 248px;
height: 288px;
background-color: transparent;
border-top: 2px solid #fff;
border-bottom: 2px solid #fff;
position: absolute;
content: '';
top: -2px;
left: 20px;
}
</style>
</head> <body>
<div id="box">
<div class="relative"></div>
<img src="ba.png" width="300" height="300" alt="心" title="心" />
</div>
</body>
</html>

[置顶] css3 befor after 简单使用 制作时尚焦点图相框的更多相关文章

  1. [置顶] Firefox OS 学习——简单了解知识

    什么是Firefox OS ? Firefox OS 是一个为网页设计而生的能编译和独立的手机网页操作系统,我们相信在接下来的时代,网页应用将充满整个新兴操作设备,这也为当前许多网页开发者不需要太多的 ...

  2. [置顶] Git 配置SSH简单玩法?

    > 第一步下载git点击直接下载 他会检测您的系统当前是64bit还是32bit安装过程不再啰嗦反正就是Next Next Next Finish 第二步这里你可以下载TortoiseGit点击 ...

  3. [置顶] 自己写一个简单通用的Makefile

    转自:http://blog.csdn.net/u011913612/article/details/52102241 一.makefile的作用 Makefile是用于自动编译和链接的,一个工程有很 ...

  4. Delphi 窗口置顶的方法

    有几种窗口置顶的方法,简单的有: ShowWindow(窗口句柄,sw_ShowNormal); SetWindowPos(窗口句柄,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOV ...

  5. css3特效第二篇--行走的线条&&置顶导航栏

    一.行走的线条. 效果图(加载可能会慢一点儿,请稍等...): html代码: <div class="movingLines"> <img src=" ...

  6. html简单响应式滚动条置顶

    简单响应式滚动条置顶 一般的,让页面出现滚动条的常见方法有: overflow:auto||overflow:scroll 或者overflow-x水平滚动条和overflow-y垂直滚动条 那么现在 ...

  7. jquery——制作置顶菜单

    置顶菜单: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  8. 仿照 QQ 的 cell 的左滑删除、置顶、标记未读效果

    侧滑删除.置顶.取消关注,在iOS8之前需要我们自定义,iOS8时苹果公司推出了新的API,UITableViewRowAction类,我们可以使用该类方便的制作出如下图的效果. 下面是实现的主要代码 ...

  9. ahk之路:利用ahk在window7下实现窗口置顶

    操作系统:win7 64位 ahk版本:autohotkey_L1.1.24.03 今天安装了AutoHotkey_1.1.24.03.SciTE.PuloversMacroCreator,重新开始我 ...

随机推荐

  1. [置顶] API相关工作过往的总结之整体介绍

    此系列的总结文章,仅仅是我个人工作总结,有考虑不周之处还请各位同行多多指教. API(Application Programming Interface,应用程序编程接口)是一些预先定义的函数,目的是 ...

  2. jquery1.7.2的源码分析(五)$.support

    $.support 的英文注释很详细的介绍的这里,就稍微的写了下 Query.support = (function() { var support, all, a, select, opt, inp ...

  3. js-权威指南学习笔记4

    第五章 语句 1.在JS中没有块级作用域,在语句块中声明的变量并不是语句块私有的. 2.尽管函数声明语句和函数定义表达式具有相同的函数名,但二者仍然不同.两种方式都创建了新的函数对象,但函数声明语句中 ...

  4. openwrt上网配置的一些理解(四)

    这次要解决的问题是3g上网和wan口上往可以随意切换,当然能够叠加也是好事,不过这不是我关心的.下面还是修改3个文件network,firewall,multiwan.首先在network中加入界面配 ...

  5. Java JDBC连接SQL Server2005错误:通过port 1433 连接到主机 localhost 的 TCP/IP 连接失败

    错误原因例如以下: Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cann ...

  6. CH BR8(小学生放假了-clock()/CLOCKS_PER_SEC-斜率优化常错集锦)

    小学生放假了 总时限 26s 内存限制 256MB 出题人 zsyzzsoft 提交情况 16/150 初始分值 1500 锁定情况 背景 我们能见到的最可怕的事情,莫过于小学生放假了! 描述 小学生 ...

  7. CoDel Test Script

    This TCL script is retrieved from http://www.pollere.net/CoDel.html in November 2013 :) # Codel test ...

  8. 惠普 hpacucli工具使用

    命令组成 hpacucli [parameter=value] 查看: 查看所有控制器状态  hpacucli ctrl all show 查看slot 0阵列信息详细状态 (可以查看物理磁盘和逻辑磁 ...

  9. C#之out与ref的共性与区别以及用法

    引入: 首先看一个例子: class Program { static void Main(string[] args) { ; int result = Test(number); Console. ...

  10. 2:numpy---ndarray

    ndarray即是多维数组[n dimension array] 一:创建ndarray 有好几种创建数组的方法. 例如,你可以使用 array 函数从常规的Python列表和元组创造数组.所创建的数 ...