CSS3 笔记一(Rounded Corners/Border Images/Backgrounds)

CSS3 Rounded Corners

  • The border-radius property is a shorthand property for setting the four border-*-radius properties.

syntax

border-radius: 1-4 length|% / 1-4 length|%|initial|inherit;
PropertyDescription
border-radiusA shorthand property for setting all the four border-*-*-radius properties
border-top-left-radiusDefines the shape of the border of the top-left corner
border-top-right-radiusDefines the shape of the border of the top-right corner
border-bottom-right-radiusDefines the shape of the border of the bottom-right corner
border-bottom-left-radiusDefines the shape of the border of the bottom-left corner

Example

 1 #rcorners7 {
 2     border-radius: 50px; 3     background: #73AD21;
 4     padding: 20px;
 5     width: 200px;
 6     height: 150px;
 7 }
 8 
 9 #rcorners8 {
10     border-radius: 15px/50px; /* elliptical corners */
11     background: #73AD21;
12     padding: 20px;
13     width: 200px;
14     height: 150px;
15 }
16 
17 #rcorners9 {
18     border-radius: 50%;
19     background: #73AD21;
20     padding: 20px;
21     width: 200px;
22     height: 150px;
23 } 

CSS3 Border Images

1> border-image

  • The border-image property is a shorthand property.

 syntax

border-image: source slice width outset repeat|initial|inherit;

2> border-image-source

  • The border-image-source property specifies the path to the image to be used as a border
border-image-source: none|image|initial|inherit;

3> border-image-slice

  • The border-image-slice property specifies how to slice the image.
  • The image is always sliced into nine sections: four corners, four edges and the middle.(九宫格)
  • The number(s) represent pixels for raster images or coordinates for vector images.(纯数字不需单位)
border-image-slice: number|%|fill|initial|inherit;

 

相关博文解析

> border-image-width

  • The border-image-width property specifies the width of the border image.

syntax

border-image-width: number|%|auto|initial|inherit;

5> border-image-outset

  • The border-image-outset property specifies the amount by which the border image area extends beyond the border box.

syntax

border-image-outset: length|number|initial|inherit;

6> border-image-repeat

  • The border-image-repeat property specifies whether the border image should be repeated, rounded or stretched.

syntax

border-image-repeat: stretch|repeat|round|initial|inherit;
ValueDescription
stretchDefault value. The image is stretched to fill the area
repeatThe image is tiled (repeated) to fill the area
roundThe image is tiled (repeated) to fill the area. If it does not fill the area with a whole number of tiles, the image is rescaled so it fits
spaceThe image is tiled (repeated) to fill the area. If it does not fill the area with a whole number of tiles, the extra space is distributed around the tiles 
initialSets this property to its default value.
inheritInherits this property from its parent element.  

border-image-repeat

CSS3 Backgrounds

1> background

  • CSS3 allows you to add multiple background images for an element.
  • The different background images are separated by commas, and the images are stacked on top of each other, where the first image is closest to the viewer.

syntax

background: color image position/size repeat origin clip attachment initial|inherit;

2> background-clip

  • The background-clip property specifies the painting area of the background.

syntax

background-clip: border-box|padding-box|content-box|initial|inherit;
ValueDescription
border-boxDefault value. The background is clipped to the border box
padding-boxThe background is clipped to the padding box
content-boxThe background is clipped to the content box
initialSets this property to its default value.
inheritInherits this property from its parent element.

3> background-origin

  •  The background-origin property specifies where the background image is positioned.

syntax

background-origin: padding-box|border-box|content-box|initial|inherit;
ValueDescription
padding-boxDefault value. The background image starts from the upper left corner of the padding edge
border-boxThe background image starts from the upper left corner of the border
content-boxThe background image starts from the upper left corner of the content
initialSets this property to its default value.
inheritInherits this property from its parent element.

Difference between background-clip and background-origin

  • The background-clip CSS property specifies whether an element's background, either the color or image, extends underneath its border.
  • The background-origin CSS property determines the background positioning area, that is the position of the origin of an image specified using the background-image CSS property.

4> background-size

  •  The background-size property specifies the size of the background images.
background-size: auto|length|cover|contain|initial|inherit;
ValueDescription
autoDefault value. The background-image contains its width and height
length

Sets the width and height of the background image. The first value sets the width, the second value sets the height.

If only one value is given, the second is set to "auto"

percentage

Sets the width and height of the background image in percent of the parent element.

The first value sets the width, the second value sets the height. If only one value is given, the second is set to "auto".

coverScale the background image to be as large as possible so that the background area is completely covered by the background image. Some parts of the background image may not be in view within the background positioning area
containScale the image to the largest size such that both its width and its height can fit inside the content area
initialSets this property to its default value.
inheritInherits this property from its parent element.

 background-size Demos

 

转载于:https://www.cnblogs.com/hzj680539/p/5089079.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值