속기 배경 속성의 배경 크기 (CSS3)
숏 핸디 드 속성 background-image
과 background-size
속성 을 혼합하려고 background
합니다. W3C 문서 에 따르면 슬래시 ( )로 구분 background-size
된 background-position
속성 뒤에 와야 /
합니다.
W3C 예 :
p { background: url("chess.png") 40% / 10em gray round fixed border-box; }
다음과 같습니다.
p { background-color: gray; background-position: 40% 50%; background-size: 10em 10em; background-repeat: round round; background-clip: border-box; background-origin: border-box; background-attachment: fixed; background-image: url(chess.png) }
MDN도 마찬가지입니다. 나는 또한 발견 이 와 이 속기 CSS3 배경 속성이 설명에 대한 기사를.
그러나 이것은 작동하지 않습니다! 또한 약식 만드는 방법을 분명하지 않다 background
속성을 때 background-size
와 background-position
두 개의 서로 다른 값을 가질 수 background-position-x
및 background-position-y
또는 같은 일 background-size
. 슬래시 ( /
)가 어떻게 발생하는지 확실하지 않습니까? 이 예 는 Chrome 15에서 작동하지 않습니다.
간략한 설명이 CSS 코드는 다음과 같습니다.
div {
background: url(http://www.placedog.com/125/125)
0 0 / 150px 100px
repeat no-repeat
fixed border-box padding-box blue;
height: 300px;
width:360px;
border: 10px dashed magenta;
}
더 깨끗한 예
이것은 작동합니다 ( JSFiddle )
body{
background-image:url(http://www.google.com/intl/en_com/images/srpr/logo3w.png);
background-position:200px 100px;
background-size:600px 400px;
background-repeat:no-repeat;
}
이것은 작동하지 않습니다 ( jsfiddle )
body{
background:url(http://www.google.com/intl/en_com/images/srpr/logo3w.png) 200px 100px/600px 400px no-repeat;
}
이것은 너무 작동하지 않습니다 ( jsfiddle )
body{
background:url(http://www.google.com/intl/en_com/images/srpr/logo3w.png) 200px/400px 100px/600px no-repeat;
}
- 귀하의 jsfiddle
background-image
대신에background
- "아직이 브라우저에서 지원되지 않는"것 같습니다.
이것은 Opera에서 작동합니다 : http://jsfiddle.net/ZNsbU/5/
그러나 FF5 또는 IE8에서는 작동하지 않습니다. (구식 브라우저의 경우 : D)
코드 :
body {
background:url(http://www.google.com/intl/en_com/images/srpr/logo3w.png) 400px 200px / 600px 400px no-repeat;
}
당신은 이렇게 할 수 있습니다 :
body {
background:url(http://www.google.com/intl/en_com/images/srpr/logo3w.png) 400px 400px no-repeat;
background-size:20px 20px
}
FF5 및 Opera에서는 작동하지만 IE8에서는 작동하지 않습니다.
당신은 할 수 있습니다
body{
background:url('equote.png'),url('equote.png');
background-size:400px 100px,50px 50px;
}
참고로 참고 사항 : 나는 이렇게 속기하려고했습니다.
background: url('../images/sprite.png') -312px -234px / 355px auto no-repeat;
but iPhone Safari browsers weren't showing the image properly with a fixed position element. I didn't check with a non-fixed, because I'm lazy. I had to switch the css to what's below, being careful to put background-size after the background property. If you do them in reverse, the background reverts the background-size to the original size of the image. So generally I would avoid using the shorthand to set background-size.
background: url('../images/sprite.png') -312px -234px no-repeat;
background-size: 355px auto;
try out like this
body {
background: #fff url("!--MIZO-PRO--!") no-repeat center 15px top 15px/100px;
}
/* 100px is the background size */
You will have to use vendor prefixes to support different browsers and therefore can't use it in shorthand.
body {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
참고URL : https://stackoverflow.com/questions/7864448/background-size-in-shorthand-background-property-css3
'programing tip' 카테고리의 다른 글
Entity Framework에 개체가 있는지 확인하는 가장 좋은 방법은 무엇입니까? (0) | 2020.08.07 |
---|---|
C에서 롤링 중간 알고리즘 (0) | 2020.08.06 |
Visual Studio에서 Interop 유형 포함 참과 거짓의 차이점은 무엇입니까? (0) | 2020.08.06 |
바이트에 대한 적절한 최대 절전 모드 주석 (0) | 2020.08.06 |
동기화 작업 대신 비동기 WebAPI 작업을 만들어야하는 이유는 무엇입니까? (0) | 2020.08.06 |