How to flip background image using CSS?
I found I way to flip only the background not whole element after seeing a clue to flip in Alex's answer. Thanks alex for your answer
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);
}
See example here http://jsfiddle.net/qngrf/807/
Flip horizontally only one background image
demo - http://jsfiddle.net/q1rf735s/1/
instead use pseudo element :before
and :after
header { width: 500px; height: 50px; display: inline-block;}header:before,header:after { content: url(http://placehold.it/50x50), url(http://placehold.it/50x50); display: block; float: left;}header:after { transform: scaleX(-1);}header ul { margin: 0 50px; padding: 0; list-style: none;}header li { float: left;}header a { width: 100px; height: 33px; padding-top: 17px; display: block; text-align: center; text-decoration: none; color: #333;}
<header> <nav> <ul> <li><a href="#">Foo</a> </li> <li><a href="#">Bar</a> </li> <li><a href="#">Foz</a> </li> <li><a href="#">Baz</a> </li> </ul> </nav></header>
how to flip a bootstrap background image
use :before
selector like below
wait for loading image background
.bg-image {
z-index: 100 !important;
color: #f1eeeef9;
}
.bg-image:before {
content:"";
position: absolute;
display: inline-block;
z-index: -1;
width:100%;
height:80px;
background:url('https://picsum.photos/600/80');
transform:scaleX(-1);
background-repeat: no-repeat;
background-size: cover;
}
<section class="bg-image">
<nav class=navbar>
<h2>Navbar</h2>
</nav>
<div class="row">
.....
</div>
</section>
Flip vertically a background-image every time it repeat-y
This cannot be done using standard CSS3 since there are no CSS3 properties to rotate a background image.
Reference: http://www.w3.org/TR/css3-background
As suggested, combine the two motifs in a single image, much simpler and will always work.
Related Topics
Clip/Crop Background-Image with CSS
Hex Colors: Numeric Representation for "Transparent"
Use Custom Fonts with Wkhtmltopdf
Change Bootstrap Carousel Fade Transition
CSS Transition Between Left -> Right and Top -> Bottom Positions
Combining Border-Top,Border-Right,Border-Left,Border-Bottom in CSS
How to Use CSS Position Sticky to Keep a Sidebar Visible with Bootstrap 4
How to Override Stylesheets of Primefaces
Font-Weight CSS Transition in Chrome
Where Do the Lost Pixels Go in a Percent CSS Layout
CSS Layout, Use CSS to Reorder Divs
Slashes ('/') in CSS Values When Using Less (E.G. in 'Font' Shorthand)
What Does This Symbol Mean in CSS
Issue with Input & Select Tag Height in Form
CSS Columns with Left-Right Flow
Getting Columns to Wrap in CSS Grid
CSS Which Takes Precedence, Inline or the Class
Make Column and Main Content Stay on Left or Right, as Browser Is Resized