CSS를 사용하여 배경 이미지를 뒤집는 방법?
CSS를 사용하여 배경 이미지를 뒤집는 방법? 가능합니까?
현재 CSS background-image
의 화살표 이미지를 사용하고 있습니다.li
켜기 : visited
이 화살표를 가로로 뒤집어 야합니다. 화살표의 다른 이미지를 만들기 위해이 작업을 수행 할 수 있지만 CSS에서 이미지를 뒤집을 수 있다는 것이 궁금합니다.:visited
CSS로 가로로 뒤집을 수 있습니다 ...
a:visited {
-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
filter: FlipH;
-ms-filter: "FlipH";
}
jsFiddle .
대신 세로로 뒤집기를 원한다면 ...
a:visited {
-moz-transform: scaleY(-1);
-o-transform: scaleY(-1);
-webkit-transform: scaleY(-1);
transform: scaleY(-1);
filter: FlipV;
-ms-filter: "FlipV";
}
소스 .
Alex의 답변에서 뒤집을 단서를 본 후 전체 요소가 아닌 배경 만 뒤집을 수있는 방법을 찾았습니다. 대답 해 주셔서 감사합니다 알렉스
HTML
<div class="prev"><a href="">Previous</a></div>
<div class="next"><a href="">Next</a></div>
CSS
.next a, .prev a {
width:200px;
background:#fff
}
.next {
float:left
}
.prev {
float:right
}
.prev a:before, .next a:before {
content:"";
width:16px;
height:16px;
margin:0 5px 0 0;
background:url(http://i.stack.imgur.com/ah0iN.png) no-repeat 0 0;
display:inline-block
}
.next a:before {
margin:0 0 0 5px;
transform:scaleX(-1);
}
여기에 예를 참조하십시오 http://jsfiddle.net/qngrf/807/
w3schools에 따르면 : http://www.w3schools.com/cssref/css3_pr_transform.asp
The transform property is supported in Internet Explorer 10, Firefox, and Opera. Internet Explorer 9 supports an alternative, the -ms-transform property (2D transforms only). Safari and Chrome support an alternative, the -webkit-transform property (3D and 2D transforms). Opera supports 2D transforms only.
This is a 2D transform, so it should work, with the vendor prefixes, on Chrome, Firefox, Opera, Safari, and IE9+.
Other answers used :before to stop it from flipping the inner content. I used this on my footer (to vertically-mirror the image from my header):
HTML:
<footer>
<p><a href="page">Footer Link</a></p>
<p>© 2014 Company</p>
</footer>
CSS:
footer {
background:url(/img/headerbg.png) repeat-x 0 0;
/* flip background vertically */
-webkit-transform:scaleY(-1);
-moz-transform:scaleY(-1);
-ms-transform:scaleY(-1);
-o-transform:scaleY(-1);
transform:scaleY(-1);
}
/* undo the vertical flip for all child elements */
footer * {
-webkit-transform:scaleY(-1);
-moz-transform:scaleY(-1);
-ms-transform:scaleY(-1);
-o-transform:scaleY(-1);
transform:scaleY(-1);
}
So you end up flipping the element and then re-flipping all its children. Works with nested elements, too.
가치가있는 것에 대해, Gecko 기반 브라우저의 :visited
경우, 개인 정보 유출로 인해이 문제를 해결할 수 없습니다 . http://hacks.mozilla.org/2010/03/privacy-related-changes-coming-to-css-vistited/를 참조 하십시오
수직과 수평 을 동시에 뒤집을 수 있습니다
-moz-transform: scaleX(-1) scaleY(-1);
-o-transform: scaleX(-1) scaleY(-1);
-webkit-transform: scaleX(-1) scaleY(-1);
transform: scaleX(-1) scaleY(-1);
그리고으로 전환 특성 당신은 멋진 플립를 얻을 수 있습니다
-webkit-transition: transform .4s ease-out 0ms;
-moz-transition: transform .4s ease-out 0ms;
-o-transition: transform .4s ease-out 0ms;
transition: transform .4s ease-out 0ms;
transition-property: transform;
transition-duration: .4s;
transition-timing-function: ease-out;
transition-delay: 0ms;
실제로는 전체 요소가 아니라background-image
단편
function flip(){
var myDiv = document.getElementById('myDiv');
if (myDiv.className == 'myFlipedDiv'){
myDiv.className = '';
}else{
myDiv.className = 'myFlipedDiv';
}
}
#myDiv{
display:inline-block;
width:200px;
height:20px;
padding:90px;
background-color:red;
text-align:center;
-webkit-transition:transform .4s ease-out 0ms;
-moz-transition:transform .4s ease-out 0ms;
-o-transition:transform .4s ease-out 0ms;
transition:transform .4s ease-out 0ms;
transition-property:transform;
transition-duration:.4s;
transition-timing-function:ease-out;
transition-delay:0ms;
}
.myFlipedDiv{
-moz-transform:scaleX(-1) scaleY(-1);
-o-transform:scaleX(-1) scaleY(-1);
-webkit-transform:scaleX(-1) scaleY(-1);
transform:scaleX(-1) scaleY(-1);
}
<div id="myDiv">Some content here</div>
<button onclick="flip()">Click to flip</button>
참고 URL : https://stackoverflow.com/questions/5768998/how-to-flip-background-image-using-css
'Programing' 카테고리의 다른 글
쿼리 문자열 매개 변수 및 숨겨진 매개 변수가 포함 된 GET 양식을 제출하면 사라집니다. (0) | 2020.04.30 |
---|---|
Akka Kill vs. Stop Pill 대 Poison Pill? (0) | 2020.04.30 |
Java의 부동 및 이중 데이터 유형 (0) | 2020.04.30 |
XPath : 값을 기준으로 요소를 선택하는 방법은 무엇입니까? (0) | 2020.04.30 |
MSSQL 오류 '기본 공급자가 열리지 못했습니다.' (0) | 2020.04.30 |