CSS中对图片(background)的一些设置心得总结_html/css_WEB-ITnose
写网页的时候很多情况需要对图片进行操作,如何在不进行专业的美工裁切操作的情况下而让自己的素材度达到最大的满意度呢,这是一个问题,对于懒得开ps切图的我,通常会直接在网络上download一张图片,直接拖到html里,这就需要对图片的css样式进行一些调整,鉴于我总是记不住一些样式属性而无法让图片按我的想法摆放,不得已每次都要百度一下,几次下来,让我很是恼火,于是专门整理了一些css中关于图片的一些属性设置,置于此,以供下次望及时查看(废话真多):
css2中关于background的属性有:
background:#eee;
backgroud-image:url("img/bg.jpg");
background-position: 0 0;//第一个数字代表x轴水平位置,第二个数字代表y轴垂直位置background-position: 0 100px;
当你的元素尺寸不适用像素设置的时候,还可以使用其他数值,如
background-position: top right; // 图片的top对应元素的top 图片的right对应元素的right background-position: 100% 50%; //使用元素的百分比数值设置图片位置,道理同上
background-repeat: repeat; //图片可重复 background-repeat: no-repeat ; //图片不可重复 background-repeat: repeat-x; //图片在x轴上可以重复 background-repeat: repeat-y; //图片在y轴上可以重复 background-repeat: inherit; //遵从父元素的设置
background-attachment: scroll; //默认值;表示背景紧贴元素background-attachment: fixed; //背景不随元素滚动,当页面向下时,背景待在最初相对于浏览器的位置background-attachment: inherit;//遵循父元素的设定
当希望设置background的多个属性时,可以分别设置每一个,也可以合并为一行,写在一个属性里:
background: transparent url(image.jpg) 50% 0 scroll repeat-y;
css3中对于background添加了很多属性:
background-size: contain; //缩小图片以适应元素的尺寸(图片宽高比不变) background-size: cover; //扩展图片以填满元素(图片宽高比不变) background-size: 50% 100%; //自定义调整图片大小
background-clip: border-box; //背景显示在边框内 background-clip: padding-box; //背景显示在padding内(不是边框内) background-clip: content-box; //只在内容内显示背景(不在padding中,也不在边框中)<br />
还有两个属性为,background-break和background-origin,我对这两个属性并没有使用过,看了看网上的讲解觉得没啥大用处,这里就不写下来误人子弟了。
css中关于背景的知识点还是很博大精深的,以后有新的理解,再往这儿添。
注:文章参考》》》》http://blog.csdn.net/adenfeng/article/details/8199362

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...
