I use this code for a menu in my site but now testing it cross-browser I see there is not compatible with firefox.
li {
display: inline-block;
list-style: none inside none;
text-align: center;
}
li a:before {
content:"";
display: block;
border-radius: 50%;
width: 62px;
height: 62px;
background: #F00;
margin: 0 auto 14px;
transition: all .2s;
}
ul.small li a:before {
-webkit-transform: scale(0.7);
-moz-transform: scale(0.7);
-ms-transform: scale(0.7);
-o-transform: scale(0.7);
background: blue;
}
ul.small-zoom li a:before {
zoom: 0.7;
background: green;
}
As you can see in this jsfiddle I tryed multiple solutions but I need the list item change width and heigth based on the a:before element and, with the scale() instruction the li dimention do not change.
There is a solution to have this in Firefow whitout fix the li dimentions?
I mostly use JavaScript to emulate zoom. Since Firefox is the only modern browser not to support it, I occasionally use it in cases where its absence does not negatively impact usability.
Here is a quick and dirty version of a generic solution:
<div data-zoom="0.5" style="zoom: 0.5">
Scaled down element
</div>
if (! ('zoom' in document.createElement('div').style)) {
setInterval(() => {
zoomed.forEach(e => {
const scale = Number(e.getAttribute('data-zoom'))
e.style.transform = 'none !important'
e.style.marginRight = '0 !important'
e.style.marginBottom = '0 !important'
const width = e.clientWidth
const height = e.clientHeight
e.style.transform = `scale(${scale})`
e.style.transformOrigin = '0 0'
const pullUp = height - height * scale
const pullLeft = width - width * scale
e.style.marginBottom = `${-pullUp}px`
e.style.marginRight = `${-pullLeft}px`
})
}, 100)
}
I just found a quick and dirty solution, but it works for my use-case, so it could help someone else too.
.zoomed {
zoom: 0.5;
}
becomes
.zoomed {
transform: scale(0.5);
margin: -50px;
}
where 50px is 1/4 of the .zoomed width.
Of course, there are many limitations of this approach - it overwrites any previous transform and margin, you have to manually insert the negative margin for each element (or calculate it with JS), and probably more.
But like I said, it worked for my specific use-case.
There is no such CSS standard property like zoom.
The reason why you code does not work in modern browsers, is that you are missing the unprefixed (standard) variant of several properties. For example when using transform:
-webkit-transform: scale(0.7);
-moz-transform: scale(0.7);
-ms-transform: scale(0.7);
-o-transform: scale(0.7);
transform: scale(0.7);
Related
I have a website which needs to be zoomed permanently with approx. 125%.
I tried:
body{
zoom: 125%;
}
Also tried:
body{
zoom: 125%;
-moz-transform: scale(1.25);
-moz-transform-origin: left top;
}
to be compatible with Mozilla Firefox.
It zooms. It was OK! But the webpage is shifted towards right i.e. its not zooming perfectly. Please help how can i fix this?
for body use
body{
-webkit-transition: opacity 1s ease;
-webkit-transform: scale(1.25);
-moz-transform: scale(1.25);
transform: scale(1.25);
zoom: 125%;
}
and for making center all content use any container like this (use max-width according to your need)
.container {
max-width: 1160px;
margin: 0 auto;
}
I have applied -webkit-transform:rotateY(180deg); to flip an image. I am applying -webkit-transform:rotateY(0deg); to rotate it back to original position. Now I have some other classes to be applied, but when I check in Chrome Inspect Element I can see that rotateY(0) is still there which should be completely removed.
How can I remove the animation completely from an Element?
.transition
{
-webkit-transform:rotateY(180deg);
transform:rotateY(180deg);
}
.notransition {
-webkit-transform:rotateY(0deg);
transform:rotateY(0deg);
}
just do this:
.transition {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.notransition {
-webkit-transform: none;
transform: none;
}
none seems to be the default value
.transition {
-webkit-transform:rotateY(180deg);
transform:rotateY(180deg);
}
.notransition {
-webkit-transform:unset;
transform:unset;
}
In my case i needed a way to override an inline transform that was being setted by third party component and i didn't want it to remove it manually.
According to Mozilla documentation, you can only transform elements:
Only transformable elements can be transformed. That is, all elements
whose layout is governed by the CSS box model except for: non-replaced
inline boxes, table-column boxes, and table-column-group boxes.
So, you can disable transform by just modifing display to a non-element one, I changed it to display:inline so the transform stops working:
.transition {
-webkit-transform:rotateY(180deg);
transform:rotateY(180deg);
}
.notransition {
display: inline;
}
Of course this will mess up with animation, however it's usefull when you are working with responsive CSS:
// small resolution / animation will stop working, and element will expand to the whole screen
.transition {
-webkit-transform:rotateY(180deg);
transform:rotateY(180deg);
}
.notransition {
display: inline;
position: fixed;
width: 100vw;
height: 100vh;
top: 0;
left: 0;
}
// medium resolution / animation works
#media print, screen and (min-width: 40em) {
.notransition {
-webkit-transform:unset;
transform:unset;
}
}
Webkit bug tracker: https://bugs.webkit.org/show_bug.cgi?id=110056
related question: Chrome CSS3 3D Transform bug
In chrome, when using css on elements with large width / height values, once a threshold of size and/or number of elements is reached, parts of the screen are no longer painted.
Please see the following test page: http://jsfiddle.net/AxkEj/35/
Note: there is transform scale on the orange container causing it to appears much smaller than the actual pixel size.
If you increase the width (as instructed on the page) to around 7000 px (depends on various factors such as screen size.
code example (to comply with SO rules):
body {
background: red;
}
body, div {
padding: 0;
margin: 0;
}
h1 {
font-size:20px;
margin:10px;
}
.wrapper {
width: 5000px;
height: 5000px;
-webkit-transform: scale(0.125);
-webkit-transform-origin: 0 0 0;
-moz-transform: scale(0.125);
-moz-transform-origin: 0 0 0;
background: orange;
}
.wrapper div {
float:left;
height:46%;
width:46%;
margin:2%;
}
.wrapper:hover > div {
-webkit-transform: rotateX(45deg);
-moz-transform: rotateX(45deg);
}
.rz {
background: violet;
}
.wrapper:hover .rz {
-webkit-transform: rotateZ(45deg);
-moz-transform: rotateZ(45deg);
}
How can I make my <div> elements grow (and the content changes text size to a higher one), when hovered over? I put them in a class and tried:
size: 150%;
and
height: +30px;
width: +30px;
the first try didn't work at all, and the second code just made the div's flash and dissappear partially.
CSS3 solution:
div {
background: #999;
width: 200px;
height: 20px;
transition: width 1s;
}
div:hover{
width: 300px;
}
<div>
<p>Im content</p>
</div>
http://jsfiddle.net/MrdvW/
I did something like this for a similar problem (you can change the scale to whatever works for you):
div:hover {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-o-transform: scale(1.1);
-ms-transform: scale(1.1);
}
Note that this will scale both the div and its content, which I think is what you want.
Using CSS you can add a hover style to the div:
div.container {
width: 80%;
background-color: blue;
}
div.container:hover {
width: 100%;
background-color: red;
}
See this jsFiddle for a demonstration.
jQuery Solution
Another option that might work for you is jQuery. It's a JavaScript library that simplifies commonly needed functionality such as this. Using jQuery, you can easily add hover effects to the elements:
//hover effect applies to any elements using the 'container' class
$(".container").hover(
function(){ //mouse over
$(this).width($(this).width() + 30);
},
function(){ //mouse out
$(this).width($(this).width() - 30);
}
);
See this jsFiddle for a demonstration.
Does anybody know if there's a double chevron symbol in unicode/HTML-space similar to the double guillemet represented by » (»)?
In other words, I'm trying to avoid using an image if I can get by with text, but I need something like this:
It's the double chevron I can't seem to figure out. Looks like graphics for me it is.
May be this site will help you http://shapecatcher.com/ , very useful!
︽ U+FE3D PRESENTATION FORM FOR VERTICAL LEFT DOUBLE ANGLE BRACKET
︾ U+FE3E PRESENTATION FORM FOR VERTICAL RIGHT DOUBLE ANGLE BRACKET
These require a Chinese or Japanese font though.
I can't give you the character entity that you want, but it's possible to effect an...alternative, and still not use images (though it does require that the text itself be wrapped in an element, in this case span):
<span class="shadowed">^</span>
<span class="rotated">»</span>
CSS:
span { /* this is all, pretty much, just for the aesthetics, and to be adapted */
margin: 0 auto 1em auto;
font-family: Helvetica, Calibri, Arial, sans-serif;
font-size: 2em;
font-weight: bold;
color: #000;
background-color: #ffa;
display: block;
width: 2em;
height: 2em;
line-height: 2em;
border-radius: 0.5em;
text-align: center;
}
span.shadowed {
text-shadow: 0 0.5em 0 #000;
}
span.rotated {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
transform: rotate(-90deg);
}
JS Fiddle demo.
The above span.rotated section, for IE < 10 compatibility (using filters, whereas IE 10 (or possibly 9) would/should use the -ms-transform or, simply, transform CSS3), using a filter approach:
span.rotated {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
transform: rotate(-90deg);
/* IE < 10 follows */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
JS Fiddle demo (works in IE 7/XP, other versions I'm unable to test).
There's a problem with rotation. If you apply rotation(90deg) and rotation(-90deg) to two separate » you'll see that their position changes. A hacky way to fix it is to apply direction: rtl like this:
http://codepen.io/tomasz86/pen/lmCaL