样式表

一、大小

1.width   宽度

2.height  高度

<div style="width:200px; height:200px"></div> 

样式和属性不同,数字后面要加上单位px或者%。

二、背景

1.背景色:background-color

<div style="width:200px; height:200px; </div>

2.背景图:background-image

<div style="width:1000px; height:800px; background-image:url(%E7%BD%91%E9%A1%B5%E8%83%8C%E6%99%AF%E5%9B%BE1.jpg)"></div>

3. 背景图平铺方式:background-repeat

<div style="width:1000px; height:800px; background-image:url(%E7%BD%91%E9%A1%B5%E8%83%8C%E6%99%AF%E5%9B%BE1.jpg); background-repeat:no-repeat"></div>

表示不平铺。

4.背景图片平铺位置:background-position
<div style="width:1000px; height:800px; background-image:url(%E7%BD%91%E9%A1%B5%E8%83%8C%E6%99%AF%E5%9B%BE1.jpg); background-repeat:no-repeat; background-position:left bottom"></div>   表示背景图在左下角(也可以直接是left、right、bottom、center、top)平铺,

<div style="width:1000px; height:800px; background-image:url(%E7%BD%91%E9%A1%B5%E8%83%8C%E6%99%AF%E5%9B%BE1.jpg); background-repeat:no-repeat; background-position:left 20px bottom 20px"></div>  表示背景图片距离左和下各20像素的距离平铺。

5.背景图是否随着页面的滚动而滚动:background-attachment

<div style="width:1000px; height:800px; background-image:url(%E7%BD%91%E9%A1%B5%E8%83%8C%E6%99%AF%E5%9B%BE1.jpg); background-repeat:no-repeat; background-position:left 20px bottom 20px; background-attachment:fixed"></div>   表示背景图片固定住,不随页面滚动而滚动。将fixed换成scroll,背景图片会随着页面滚动而滚动

6.背景图片大小: background-size

<div style="width:1000px; height:800px; background-color:#33C; background-image:url(%E7%BD%91%E9%A1%B5%E8%83%8C%E6%99%AF%E5%9B%BE1.jpg); background-repeat:no-repeat; background-position:left 20px bottom 20px; background-attachment:fixed; background-size:200px 200px"></div>  表示背景图片的大小为200px × 200px ,auto表示自动的。

三、字体

1.字体样式 font-family,一般选用电脑常见字体,如微软雅黑和仿宋。<div style="font-family:微软雅黑">文字</div>

2.字体大小 font-size   一般在网页里面常用的比较小的字体是12px,正常阅读的文字的大小是14px,16px也可以用,但是一般阅读的类型的不要超过16px。

<div style="font-family:微软雅黑; font-size:18px">测试文字</div>

3.字体样式 font-style   italic表示倾斜

<div style="font-family:微软雅黑; font-size:18px; font-style: italic">测试文字</div>

4.字体粗细 font-weight    bold表示加粗

 <div style="font-family:微软雅黑; font-size:18px; font-style: italic; font-weight:bold">测试文字</div>

5.装饰线 text-decoration     underline表示下划线   overline表示上划线    line-through表示删除线    none表示没有,经常用来去掉超链接的下划线。

 <div style="font-family:微软雅黑; font-size:18px; font-style: italic; font-weight:bold; text-decoration:underline">测试文字</div>

6.字体颜色  color

<div style="font-family:微软雅黑; font-size:18px; font-style: italic; font-weight:bold; text-decoration:underline; color:#F00">测试文字</div>

四、对齐方式

1.水平对齐方式  text-align

<div style="width:200px; height:200px; color:#FFF; text-align:center">测试文字</div>

2.垂直对齐方式  vertical-align     配合行高(line-height)使用。

3.行高  line-height

 <div style="width:200px; height:200px; color:#FFF; text-align:center; vertical-align:middle; line-height:200px">测试文字</div>

4.缩进  text-indent   单位:像素

<div style="width:200px; height:200px; color:#FFF; text-align:center; vertical-align:middle; line-height:200px; text-indent:30px">测试文字</div>

五、边界与边框

1.外边距 margin  方向:上右下左   顺时针

<div style="width:300px; height:300px;
<div style="width:200px; height:200px; background-color:#CF9; margin:10px 0px 0px 10px; float:left"></div>
</div>

float为流向,在以后的布局中会学,在这不加上边距不起作用。

2.内边距 padding 方向:上右下左   顺时针

如果加了内边距,该元素会相应的变大。

3.边框 border   border代表四个方向全有。

<div style="width:200px; height:200px; border:1px solid #60F"></div>

1px solid #60F  简写方式  第一个边框粗细  第二个边框样式  第三个边框颜色

												

9月9日下午HTML样式表(宽度和高度、背景字体、对齐方式边界与边框)的更多相关文章

  1. 12月15日下午Smarty模板函数

    1.{$var=...} 这是{assign}函数的简写版,你可以直接赋值给模版,也可以为数组元素赋值. <{$a = 10}><!--赋值语句--> <{$a}> ...

  2. 11月10日下午 ajax做显示信息以后用ajax、Bootstrp做弹窗显示信息详情

    1.用ajax做弹窗显示信息详情 nation.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&qu ...

  3. 9月22日下午JavaScript----Document对象

    document对象 一.找元素 1.根据id找 示例: <input id = "a" type="button" value="找元素&qu ...

  4. 2017年10月21日 CSS常用样式&鼠标样式 以及 jQuery鼠标事件& jQuery图片轮播& jQuery图片自动轮播代码

    css代码 背景与前景 background-color:#0000; //背景色,样式表优先级高 background-image:url(路径); //设置背景图片 background-atta ...

  5. css样式表----------样式属性(背景与前景、边界和边框、列表与方块、格式与布局)

    一.背景与前景 (1).背景 line-height: 1.5 !important;">90; /*背景色(以样式表为主,样式表优先.)*/ background-image:url ...

  6. 10月30日下午 PHP精确查询(模糊查询、模糊+关键字共同查询)

    1.一个条件的模糊查询 <body> <br /> <form action="main.php" method="post"&g ...

  7. 10月28日下午MySQL数据库的增加、删除、查询(匹配数据库登录和可以增、删、查的显示数据库内容的页面))

    一.匹配数据库登录 步骤: 1.做一个普通的登录界面,注意提交方式为post. <!--登录界面--> <form action="chuli.php" meth ...

  8. 10月21日下午PHP常用函数

    函数四要素:返回类型  函数名  参数列表  函数体 //最简单的函数定义方式 function Show() { echo "hello"; } Show();//输出结果为he ...

  9. 10月17日下午MySQl数据库CRUD高级查询

    高级查询:1.连接查询 #适用于有外键关系的  没有任何关系没法用select * from Info,Nation #同时查询这俩表并把两表每个数据相互组合,形成笛卡尔积 select * from ...

随机推荐

  1. Hadoop配置安装手册

    本次Hadoop集群安装一共使用四个节点,各节点IP如下: Master 172.22.120.191 Slave1 172.22.120.192 Slave2 172.22.120.193 Slav ...

  2. css3实现的3中loading动画效果

    一.css3中animation动画各种属性详解: animation Value:     [<animation-name> || <animation-duration> ...

  3. js和jQuery的日常

    让当前页面显示整个屏幕 - (iframe 从后台跳转到前台的时候容易多层嵌套)$(document).ready(function(){ if(window.top != window.self) ...

  4. double截取小数点位数

    (double)decimal.Round(decimal.Parse((planVoSt.TotalCompleteAmount / planVoSt.TotalUserCount).ToStrin ...

  5. C++强制类型转换操作符 static_cast

    static_cast是一个强制类型转换操作符.强制类型转换,也称为显式转换,C++中强制类型转换操作符有static_cast.dynamic_cast.const_cast.reinterpert ...

  6. 编译hadoop-2.5.2总结

    原文:http://www.cnblogs.com/qigang/p/4194728.html 一.准备的资料 64位linux系统.我使用的是 CentOS JDK 1.7+.注:使用1.7即可,如 ...

  7. bzoj 3224 splay模板题4

    再刷水题我就废了... #include<iostream> #include<cstdio> #include<algorithm> #include<cs ...

  8. 【BZOJ-3450】Tyvj1952Easy 概率与期望DP

    3450: Tyvj1952 Easy Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 468  Solved: 353[Submit][Status] ...

  9. 【poj1160】 Post Office

    http://poj.org/problem?id=1160 (题目链接) 题意 按照递增顺序给出一条直线上坐标互不相同的n个村庄,要求从中选择p个村庄建立邮局,每个村庄使用离它最近的那个邮局,使得所 ...

  10. 订阅Jenkins的邮件列表,获取最新的信息

    进入https://jenkins.io/content/mailing-lists/ 点击感兴趣的话题 选择[archive]跳转到谷歌讨论组 最后,点击左上角的[Subscribe]即可加入Goo ...