当前位置: 首页 > news >正文

css学习笔记

h1 {color:red; font-size:14px;}
p {font-family: "sans serif";}
text-align: center;
background: #fff;
margin: 0;
padding: 0;

选择器的分组
h1,h2,h3,h4,h5,h6 {
color: green;
}
继承及其问题
body {
font-family: Verdana, sans-serif;
}

body {
font-family: Verdana, sans-serif;
}

td, ul, ol, ul, li, dl, dt, dd {
font-family: Verdana, sans-serif;
}

p {
font-family: Times, "Times New Roman", serif;
}

派生选择器
li strong {
font-style: italic;
font-weight: normal;
}

id选择器
#red {color:red;}
#green {color:green;}

类选择器
.center {text-align: center}

属性选择器
[title=W3School]
{
border:5px solid blue;
}

css的引用
<link rel="stylesheet" type="text/css" href="mystyle.css" />

内部创建css
<style type="text/css">
hr {color: sienna;}
p {margin-left: 20px;}
body {background-image: url("images/back40.gif");}
</style>

背景
body
{
background-image: url(/i/eg_bg_03.gif);
background-repeat: repeat-y;
}

body
{
background-image:url('/i/eg_bg_03.gif');
background-repeat:no-repeat;
background-position:center; background-position:top;

background-position属性

单一关键字 等价的关键字
center center center
top top center 或 center top
bottom bottom center 或 center bottom
right right center 或 center right
left left center 或 center left

background-attachment:fixed 背景图片固定

a {text-decoration:none;}

p.uppercase {text-transform:uppercase;}
p.lowercase {text-transform:lowercase;}
p {text-indent:50px;}
h1 {letter-spacing:2px;}
h2 {letter-spacing:-3px;} 字符之间间距
p.small {line-height:70%;}
p.big {line-height:200%;} 行间距

word-spacing:30px; 单词间空白
img.top {vertical-align:text-top;}
img.bottom {vertical-align:text-bottom;}垂直对齐
}

h1 {text-shadow:2px 12px #FF0000;} 字符阴影

a:link - 正常,未访问过的链接
a:visited - 用户已访问过的链接
a:hover - 当用户鼠标放在链接上时
a:active - 链接被点击的那一刻


ul样式
list-style-image:url('sqpurple.gif');

vertical-align:bottom; 对齐

border-collapse:collapse;

boder样式
p.none {border-style:none;}
p.dotted {border-style:dotted;} 虚线
p.dashed {border-style:dashed;}长虚线
p.solid {border-style:solid;} 实线
p.double {border-style:double;}双实线
p.groove {border-style:groove;}
p.ridge {border-style:ridge;}
p.inset {border-style:inset;}
p.outset {border-style:outset;}
p.hidden {border-style:hidden;}

设置最大高度
max-height:50px

设置隐藏
h1.hidden {visibility:hidden;}
h1.hidden {display:none;}

固定
p.pos_fixed
{
position:fixed;
top:30px;
right:5px;
}

相对
position:relative;
left:-20px;

绝对定位
position:absolute;
left:100px;
top:150px; 重叠元素 z-index:-1; overflow:scroll; overflow:auto;

清除浮动
clear:both;

后代选取器 div p
子元素选择器 div>p
相邻兄弟选择器div+p
普通相邻兄弟选择器div~p

伪类
p:first-child
{
color:blue;
}

focus伪类
:before
:after

a标签 设置display:block; 才会影响width height属性

li 是快元素,但是设置内链
{
display:inline;
}
设置图片透明度
img
{
opacity:0.4;
filter:alpha(opacity=40); /* For IE8 and earlier */
}
img:hover
{
opacity:1.0;
filter:alpha(opacity=100); /* For IE8 and earlier */


、图像拼接:
<img class="aa" src="/images/img_trans.gif">
img.aa {
width: 43px;
height: 44px;
background: url(/images/img_navsprites.gif) -181px 0;
}


css3 新的样式
border-radius
box-shadow box-shadow: 10px 10px 50px #888888; 参数X,Y 大小,颜色
border-image
border-image:url(border.png) 30 30 round;
border-image:url(border.png) 30 30 stretch;

渐变
#grad {
background: -webkit-linear-gradient(red, blue); /* Safari 5.1 - 6.0 */
background: -o-linear-gradient(red, blue); /* Opera 11.1 - 12.0 */
background: -moz-linear-gradient(red, blue); /* Firefox 3.6 - 15 */
background: linear-gradient(red, blue); /* 标准的语法 */
}

换行
word-wrap:break-word;

字体
@font-face
{
font-family: myFirstFont;
src: url('Sansation_Light.ttf')
,url('Sansation_Light.eot'); /* IE9 */
}

div
{
font-family:myFirstFont;
}

过度
transition:width 0.5;
-webkit-transition:width 0.5s; /* Safari */
div:hover
{
width:300px;
}

-webkit-transition: width 2s, height 2s, -webkit-transform 2s; /* For Safari 3.1 to 6.0 */
transition: width 2s, height 2s, transform 2s;


动画
div
{
width:100px;
height:100px;
background:red;
animation:myfirst 5s;
-webkit-animation:myfirst 5s; /* Safari and Chrome */
}

@keyframes myfirst
{
from {background:red;}
to {background:yellow;}
}

@-webkit-keyframes myfirst /* Safari and Chrome */
{
from {background:red;}
to {background:yellow;}
}

多列排列
.newspaper
{
-moz-column-count:3; /* Firefox */
-webkit-column-count:3; /* Safari and Chrome */
column-count:3;
}

-moz-column-count:3; /* Firefox */
-webkit-column-count:3; /* Safari and Chrome */
column-count:3;

-moz-column-gap:40px; /* Firefox */
-webkit-column-gap:40px; /* Safari and Chrome */
column-gap:40px;

-moz-column-rule:4px outset #ff00ff; /* Firefox */
-webkit-column-rule:4px outset #ff00ff; /* Safari and Chrome */
column-rule:4px outset #ff00ff;

转载于:https://www.cnblogs.com/wwx-blog/p/4627171.html

相关文章:

  • [windows phone 7开发]搭建WP7开发环境
  • LoadRunner8测试Web站点
  • WCF技术剖析之一:通过一个ASP.NET程序模拟WCF基础架构
  • 发现live555中一个小bug(2)
  • 转载:APP的上线和推广——线上推广渠道
  • 关于HashMap的建值取向
  • 【软件】Eclipse 下载
  • web service 开源项目比较
  • SOSO发布通用搜索引擎优化指南
  • 超越死亡:恩宠与勇气节选
  • linux进程与它的文件描述符2
  • 操作笔记:catalina.out膨胀太快,分割tomcat 7日志
  • [转载]GSview注册码
  • ******IT公司面试题汇总+优秀技术博客汇总
  • iphone 如何设置按钮透明,文字不透明
  • android 一些 utils
  • js算法-归并排序(merge_sort)
  • Linux链接文件
  • npx命令介绍
  • React Native移动开发实战-3-实现页面间的数据传递
  • Stream流与Lambda表达式(三) 静态工厂类Collectors
  • vue中实现单选
  • 安装python包到指定虚拟环境
  • 机器学习中为什么要做归一化normalization
  • 基于Dubbo+ZooKeeper的分布式服务的实现
  • 看域名解析域名安全对SEO的影响
  • 浅谈web中前端模板引擎的使用
  • 我的业余项目总结
  • 由插件封装引出的一丢丢思考
  • ionic异常记录
  • # Maven错误Error executing Maven
  • #define与typedef区别
  • $(document).ready(function(){}), $().ready(function(){})和$(function(){})三者区别
  • (C语言)球球大作战
  • (ibm)Java 语言的 XPath API
  • (Matalb时序预测)PSO-BP粒子群算法优化BP神经网络的多维时序回归预测
  • (TOJ2804)Even? Odd?
  • (原創) 如何讓IE7按第二次Ctrl + Tab時,回到原來的索引標籤? (Web) (IE) (OS) (Windows)...
  • .net core 3.0 linux,.NET Core 3.0 的新增功能
  • .NET 服务 ServiceController
  • .NET(C#、VB)APP开发——Smobiler平台控件介绍:Bluetooth组件
  • .NET开源的一个小而快并且功能强大的 Windows 动态桌面软件 - DreamScene2
  • .NET轻量级ORM组件Dapper葵花宝典
  • ?php echo $logosrc[0];?,如何在一行中显示logo和标题?
  • @31省区市高考时间表来了,祝考试成功
  • @hook扩展分析
  • [ C++ ] STL_list 使用及其模拟实现
  • [ C++ ] STL---string类的使用指南
  • [1159]adb判断手机屏幕状态并点亮屏幕
  • [2016.7 day.5] T2
  • [Asp.net MVC]Asp.net MVC5系列——Razor语法
  • [AutoSar]工程中的cpuload陷阱(三)测试
  • [C++]——带你学习类和对象
  • [C和指针].(美)Kenneth.A.Reek(ED2000.COM)pdf
  • [EFI]Atermiter X99 Turbo D4 E5-2630v3电脑 Hackintosh 黑苹果efi引导文件