CSS样式1
编写CSS样式:
1.标签的style属性
如:<div style="width:980px;"></div>
2.写在head里面,style标签中写样式(各类选择器)
- id选择器
#i1{
background-color:#2459a2;
height:48px;
}
- class选择器
.名称{
...
}
<标签 class='名称'></标签>
- 标签选择器
div{
...
}
所有div设置上此样式
- 层级选择器(空格)
.c1 .c2 div{
...
}
- 组合选择器(逗号)
#c1,.c2,div{
...
}
- 属性选择器
对选择到的标签再通过属性再进行一次筛选
.c1[n='alex']{
...
}
PS:
- 优先级,标签上style优先,编写顺序,就近原则
3.css样式也可以写在单独文件中
<link rel='stylesheet' href='commons.css' />
4.注释
/* */
5.边框
- 宽度,样式,颜色 (border:4px dotted red;)
- border-left
6.
height 高度 像素,百分比
width 宽度 像素,百分比
text-align:center 水平方向居中
line-height 垂直方向根据标签高度
color 字体颜色
font-size 字体大小
font-weight 字体加粗
7.背景
8.float
让标签浪起来,块级标签可以堆叠
老子管不住:
<div style='clear:both;'></div>
9.display
display:None; --让标签消失
display:inline;
display:block;
display:inline-block;
具有inline默认自己有多少占多少
具有block,可以设置高度,宽度,padding margin
******
行内标签inline:无法设置宽度,高度,padding margin
块级标签block:可以设置高度,宽度,padding margin
10.padding margin(0,auto)
-div块居中使用margin:0 auto;
<div style="width:500px;height:200px;background-color:black;position:relative;margin:0 auto;"> </div>
- padding属性的顺序:上、右、下、左;
padding:0 10px 0 10px; 等价于 padding:0 auto;
CSS样式1的更多相关文章
- css样式让input垂直居中
css样式让input垂直居中 css代码: .div1{ border: 1px solid #CCC; width:1120px; height:40px; margin:auto; displa ...
- 深度理解CSS样式表,内有彩蛋....
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- js设置css样式.
在js设置css样式做法 var obj = document.getElementById('div'); obj.style.width = '100px'; obj.style.height = ...
- CSS样式表
CSS样式及属性 样式标的基本概念 样式表的分类 1.内联样式表 和html联合显示,控制精确,但可重用性差,冗余多. 例:<p style="font-size:14px;" ...
- 脚本工具(获取某个文件夹下的所有图片属性批量生成css样式)
问题描述: 由于有一次工作原因,就是将某个文件夹下的所有图片,通过CSS描述他们的属性,用的时候就可以直接引用.但是我觉得那个文件夹下的图片太多,而且CSS文件的格式又有一定的规律,所有想通过脚本来生 ...
- jQuery所支持的css样式
jQuery所支持的css样式 backgroundPosition borderWidth borderBottomWidth borderLeftWidth borderRightWidth bo ...
- Yii2 assets注册的css样式文件没有加载
准备引入layui.css文件的,在LayuiAssets类中已经配置了资源属性 <?php namespace frontend\assets; use yii\web\AssetBundle ...
- 获取元素计算后的css样式封装
获取元素计算后的css样式封装: function getCss(obj,attribute) { if(obj.currentStyle) { return obj.currentStyle[att ...
- JS实战 · 仿css样式选择器
代码如下: <html> <head> <meta http-equiv="Content-Type" content="text/ ...
- CSS样式之优先级
说到到css的样式优先级,今天偶再来回顾下,从css的样式优先级可分为两个部分: 1.从CSS代码放置的位置看权重优先级: 内联样式 > 内部嵌入样式 >外联样式 2.从样式选择器 ...
随机推荐
- chrome浏览器的json格式化插件
JSON-Handle 下载地址: http://jsonhandle.sinaapp.com/ 插件下载后,在浏览器输入:chrome://extensions/ 将下载后的文件 ...
- 1043 Is It a Binary Search Tree (25分)(树的插入)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following propertie ...
- 1030 Travel Plan (30分)(dijkstra 具有多种决定因素)
A traveler's map gives the distances between cities along the highways, together with the cost of ea ...
- 部署并测试动态WSGI站点
部署并测试动态WSGI站点 5.1问题 本例要求为站点webapp0.example.c ...
- Jmeter 压力测试笔记(2)--问题定位
事情已经出了,是该想办法解决的时候了. 经过运维和DBA定位: 数据库读写分离中,读库延时超过了30秒,导致所有请求都压在主库.另外所有数据库都连接数都被占满,但活跃请求数量缺不多. 数据库16K的连 ...
- Java中toString()与new String()
Java中toString()与new String(): 1.错误演示: FileInputStream fileIn = new FileInputStream(filePath);byte[] ...
- PHP 学习笔记摘要
文章更新于2020-03-17 文章目录 一.基础知识 二.知识点细节说明 (1)boolean 布尔型 (2)string 字符串型 (3)integer 整型 (4)float 浮点型 (5)ar ...
- TP5快速入门
一.查询 //order支持使用数组对多个字段的排序,例如order(['order','id'=>'desc']) //group方法只有一个参数,并且只能使用字符串. //having方法只 ...
- MySQL中information_schema 数据库 是干什么的
MySQL中information_schema是什么 大家在安装或使用MYSQL时,会发现除了自己安装的数据库以外,还有一个information_schema数据库. information_sc ...
- 关于在React中 报Super expression must either be null or a function, not undefined (采坑系列)
今天突然在联系React中遇到一开始就报 Super expression must either be null or a function, not undefined 百度,各种方法,.. ...