CSS背景background图片
一、CSS背景background图片 - TOP
1、背景图片语法
background-image:url() 引入背景图片
background-repeat:no-repeat 设置背景图片是否重复平铺
background-position:left top 设置图片的css背景定位,left代表靠左,top代表靠上
简写背景图片语法:
background:url(图片地址) no-repeat left top
2、背景图片设置
Body{background:url(http://www.divcss5.com/img201301/divcss5-logo-2013.gif) no-repeat 0 0 }
这里设置了图片“http://www.divcss5.com/img201301/divcss5-logo-2013.gif”作为网页背景不重复并靠上靠左显示。,
3、CSS背景图居中
横向居中:
background:url(图片地址) no-repeat center top
纵向居中:
background:url(图片地址) no-repeat left 50%
这里50%是随意设置考上为50%距离,细节具体上下垂直居中需要再通过百分比均衡设置。
4、背景图片一般案例
Body设置网页背景css代码
body{background:url(http://www.divcss5.com/img201301/divcss5-logo-2013.gif) no-repeat 0 0}
CSS图片背景案例截图

不重复也不平铺图片背景截图
5、div css背景图片居中
Css背景图片居中代码:
body{background:url(http://www.divcss5.com/img201301/divcss5-logo-2013.gif) no-repeat center 0}
这里我们用了“center ”居中属性,更多详情可进入css 背景了解基础
居中截图

背景图片居中于网页截图
6、背景图片横向平铺
CSS背景X横向平铺代码:
body{background:url(http://www.divcss5.com/img201301/divcss5-logo-2013.gif) repeat-x}
案例截图:

Y轴横向平铺图片背景截图
7、背景图片纵向平铺
CSS背景Y纵向平铺代码:
body{
background:url(http://www.divcss5.com/img201301/divcss5-logo-2013.gif) repeat-y
}
平铺重复图片背景效果截图:

纵向Y轴方向垂直平铺图片背景截图
8、全网页背景图片重复平铺
图片背景全屏网页重复平铺关键代码:
body{background:url(http://www.divcss5.com/img201301/divcss5-logo-2013.gif)}
截图:

图片作为背景全屏平铺显示截图
说明:这里没有设置是否重复,是否居左居右,只设置背景引入图片即可简便地实现图片自然全屏平铺
二、CSS背景颜色 - TOP
1、background背景颜色语法
background:#FFF
.divcss5{background:#FFF}
设置了divcss5对象背景为白色
2、背景颜色案例
假如我们设置网页背景全部为白色,文字颜色为白色
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>无标题文档</title>
- <style>
- body{background:#000; color:#FFF}
- </style>
- </head>
- <body>
- DIVCSS5 背景为黑色;文字颜色为白色
- </body>
- </html>
2)、背景颜色与文字颜色案例截图

CSS设置背景颜色与CSS字体颜色
如果想了解CSS背景颜色与CSS图片背景同时设置background基础进入:http://www.divcss5.com/rumen/r125.shtml
三、背景为颜色与为图片总结 - TOP
我们使用css background设置图片为网页背景,图片为网页背景各种样式,包括了是否背景图片居中,是否背景图片重复平铺显示、是否固定背景图片位置等背景样式,以上知识点与案例点希望大家自己复制以上代码实践观察即可掌握。
扩展阅读:
CSS文字颜色
CSS字体颜色
CSS背景
CSS background
CSS背景background图片的更多相关文章
- CSS背景background、background-position使用详解
背景(background)是css中一个重要的的部分,也是需要知道的css的基础知识之一.这篇文章将会涉及css背景(background)的基本用法,包括诸如 background-attachm ...
- CSS背景background详解,background-position详解
背景(background)是css中一个重要的的部分,也是需要知道的css的基础知识之一.这篇文章将会涉及css背景(background)的基本用法,包括诸如 background-attachm ...
- CSS 背景background实例
css背景background用于设置html标签元素的背景颜色.背景图片已经其他背景属性.本文章向码农介绍CSS 背景background使用方法和基本的使用实例.需要的码农可以参考一下. 一.Cs ...
- CSS 背景 background 讲解
背景语法:background: background-color || background-image || background-repeat || background-attachment ...
- CSS背景-background
复合属性-background 如果同时设置了background-color和background-image时,背景颜色会被图片覆盖. background-image: 用作背景的图片,back ...
- css 背景 background
前言:这是笔者学习之后自己的理解与整理.如果有错误或者疑问的地方,请大家指正,我会持续更新! background我们一般用到的的属性有: background-attachment:背景(图片)是否 ...
- css 背景(background)属性、背景图定位
background属性: Background属性是css中应用比较多,且比较重要的一个属性,它是负责给盒子设置背景图上和背景颜色的,background是一个复合属性,它可以分解成如下几个设置项: ...
- css设置background图片的位置实现居中
/* 例 1: 默认值 */ background-position: 0 0; /* 元素的左上角 */ /* 例 2: 把图片向右移动 */ background-position: 75px 0 ...
- css常用样式背景background如何使用
css背景background属性常用于定义HTML的背景,background简写属性作用是将背景属性设置在一个声明中,background背景属性常见为以下这些:.background-color ...
随机推荐
- LeetCode OJ 79. Word Search
题目 Given a 2D board and a word, find if the word exists in the grid. The word can be constructed fro ...
- ANg-基础概念
分类 机器学习可以分为两类:监督学习(Supervised Learning)和无监督学习(Unsupervised Learning) 监督学习 Supervised Learning 监督学习是从 ...
- django 运行脚本
转自:https://segmentfault.com/a/1190000006752130 runscript 命令会首先检查每个 app 下的 scripts 目录,如果找到对应名字的脚本就会执行 ...
- 基于ajax请求异常捕获
第一步:controller中 @RequestMapping("/ajaxerror") public String ajaxerror() { return "thy ...
- windows 10 专业版 激活
参考文章:https://jingyan.baidu.com/article/c14654134b99de0bfcfc4c8c.html http://www.windowszj.com/news/2 ...
- Ubuntu 下 redmine 安装配置
安装 rvm \curl -L https://get.rvm.io | bash -s stable --ruby --autolibs=enable –auto-dotfiles 安装 Ruby ...
- BeanFactory的实现原理
先来看看Java代码获取Spring中Bean的代码(一共有五种方式,这里只展示其中一种方法): 有没有发现上面的代码与利用反射实现工厂模式的代码很相似.对,你没有看错,Spring中的BeanFac ...
- SAP 使用
SAP 提供多种方法查找系统内的事务代码 1. 使用SE11查看存储事物代码的表:TSTC 或者TSTCT TSTC: 存有事务代码,程序名称,屏幕号码等字段 TSTCT: 存有语言代码,事务代码,事 ...
- vue --轮播图
轮播图,可以使用mint-ui中的swipe HTML: <Swipe :auto="4000"> <SwipeItem v-for="item in ...
- Real Time Rendering 2
[Real Time Rendering 2] 1.The light vector l is usually defined pointing in a direction opposite to ...