how to define breakpoints in elevation prop in Paper In MUI - javascript

I am using MUI5 in my Project. Its great. I have designed a login page. In the Page, I have used Paper Component
In the Paper Component, I want to define Elevation. I can define it using this
<Paper elevation={7}>
It works. But My need was. For mobile screen/Tab screen, I don't want elevation.So I did like this
<Paper elevation={{md:7}}>
But it's not working. Please Help me with some solutions
Here's the Code in my Sand Box
https://codesandbox.io/s/loginpage-6ko3qs?file=/src/App.js

Welcome to Stackoverflow #sameho
The Paper's elevation prop simply maps Material UI's theme.shadows to box-shadow based on the number.
So you can do this instead of using elevation altogether:
<Paper
sx={{
width: 500,
height: 300,
backgroundColor: "white",
padding: 5,
pb: 10,
boxShadow: { xs: "none", md: "0px 4px 5px -2px rgba(0,0,0,0.2),0px 7px 10px 1px rgba(0,0,0,0.14),0px 2px 16px 1px rgba(0,0,0,0.12)" }
}}
>
.....
</Paper>
Sandbox: https://codesandbox.io/s/loginpage-forked-zdijmv?file=/src/App.js
These are all the boxShadow attributes that MUI uses for their elevation prop:
0: "none"
1: "0px 2px 1px -1px rgba(0,0,0,0.2),0px 1px 1px 0px rgba(0,0,0,0.14),0px 1px 3px 0px rgba(0,0,0,0.12)"
2: "0px 3px 1px -2px rgba(0,0,0,0.2),0px 2px 2px 0px rgba(0,0,0,0.14),0px 1px 5px 0px rgba(0,0,0,0.12)"
3: "0px 3px 3px -2px rgba(0,0,0,0.2),0px 3px 4px 0px rgba(0,0,0,0.14),0px 1px 8px 0px rgba(0,0,0,0.12)"
4: "0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12)"
5: "0px 3px 5px -1px rgba(0,0,0,0.2),0px 5px 8px 0px rgba(0,0,0,0.14),0px 1px 14px 0px rgba(0,0,0,0.12)"
6: "0px 3px 5px -1px rgba(0,0,0,0.2),0px 6px 10px 0px rgba(0,0,0,0.14),0px 1px 18px 0px rgba(0,0,0,0.12)"
7: "0px 4px 5px -2px rgba(0,0,0,0.2),0px 7px 10px 1px rgba(0,0,0,0.14),0px 2px 16px 1px rgba(0,0,0,0.12)"
8: "0px 5px 5px -3px rgba(0,0,0,0.2),0px 8px 10px 1px rgba(0,0,0,0.14),0px 3px 14px 2px rgba(0,0,0,0.12)"
9: "0px 5px 6px -3px rgba(0,0,0,0.2),0px 9px 12px 1px rgba(0,0,0,0.14),0px 3px 16px 2px rgba(0,0,0,0.12)"
10: "0px 6px 6px -3px rgba(0,0,0,0.2),0px 10px 14px 1px rgba(0,0,0,0.14),0px 4px 18px 3px rgba(0,0,0,0.12)"
11: "0px 6px 7px -4px rgba(0,0,0,0.2),0px 11px 15px 1px rgba(0,0,0,0.14),0px 4px 20px 3px rgba(0,0,0,0.12)"
12: "0px 7px 8px -4px rgba(0,0,0,0.2),0px 12px 17px 2px rgba(0,0,0,0.14),0px 5px 22px 4px rgba(0,0,0,0.12)"
13: "0px 7px 8px -4px rgba(0,0,0,0.2),0px 13px 19px 2px rgba(0,0,0,0.14),0px 5px 24px 4px rgba(0,0,0,0.12)"
14: "0px 7px 9px -4px rgba(0,0,0,0.2),0px 14px 21px 2px rgba(0,0,0,0.14),0px 5px 26px 4px rgba(0,0,0,0.12)"
15: "0px 8px 9px -5px rgba(0,0,0,0.2),0px 15px 22px 2px rgba(0,0,0,0.14),0px 6px 28px 5px rgba(0,0,0,0.12)"
16: "0px 8px 10px -5px rgba(0,0,0,0.2),0px 16px 24px 2px rgba(0,0,0,0.14),0px 6px 30px 5px rgba(0,0,0,0.12)"
17: "0px 8px 11px -5px rgba(0,0,0,0.2),0px 17px 26px 2px rgba(0,0,0,0.14),0px 6px 32px 5px rgba(0,0,0,0.12)"
18: "0px 9px 11px -5px rgba(0,0,0,0.2),0px 18px 28px 2px rgba(0,0,0,0.14),0px 7px 34px 6px rgba(0,0,0,0.12)"
19: "0px 9px 12px -6px rgba(0,0,0,0.2),0px 19px 29px 2px rgba(0,0,0,0.14),0px 7px 36px 6px rgba(0,0,0,0.12)"
20: "0px 10px 13px -6px rgba(0,0,0,0.2),0px 20px 31px 3px rgba(0,0,0,0.14),0px 8px 38px 7px rgba(0,0,0,0.12)"
21: "0px 10px 13px -6px rgba(0,0,0,0.2),0px 21px 33px 3px rgba(0,0,0,0.14),0px 8px 40px 7px rgba(0,0,0,0.12)"
22: "0px 10px 14px -6px rgba(0,0,0,0.2),0px 22px 35px 3px rgba(0,0,0,0.14),0px 8px 42px 7px rgba(0,0,0,0.12)"
23: "0px 11px 14px -7px rgba(0,0,0,0.2),0px 23px 36px 3px rgba(0,0,0,0.14),0px 9px 44px 8px rgba(0,0,0,0.12)"
24: "0px 11px 15px -7px rgba(0,0,0,0.2),0px 24px 38px 3px rgba(0,0,0,0.14),0px 9px 46px 8px rgba(0,0,0,0.12)"

Related

How to add image extension on css image?

I converted image to css. Now i wants to give image extension manually on my code. All code will run as a jpg/png format and will display image.
I tried php code: header('content-type: image/png') but i am not success, image not displaying (i got black page). If i use image extension then i can display image on social media. Now its displaying on my site but not displaying in social media. please don't tell me to use real image without convert. is it possible to fetch only css image on social media? Thanks
.img{height: 1px; width: 1px; box-shadow: #b55e31 0 0,#d48564 1px 0,#733125 2px 0,#623436 3px 0,#5f494c 4px 0,#705b6c 5px 0,#502a53 6px 0,#863c79 7px 0,#d859aa 8px 0,#d22f8a 9px 0,#c70d70 10px 0,#da1773 11px 0,#e82372 12px 0,#ff588c 13px 0,#d23d50 14px 0,#7b0000 15px 0,#7f0104 16px 0,#800300 17px 0,#931200 18px 0,#981600 19px 0,#843911 0 1px,#823d1e 1px 1px,#5c2318 2px 1px,#5f3134 3px 1px,#451c2c 4px 1px,#a27491 5px 1px,#e0a1d0 6px 1px,#de7fbf 7px 1px,#c03986 8px 1px,#c9257b 9px 1px,#c00963 10px 1px,#ce0e63 11px 1px,#db1b66 12px 1px,#d12056 13px 1px,#a9152d 14px 1px,#860007 15px 1px,#840000 16px 1px,#8f0d00 17px 1px,#9a1900 18px 1px,#cb4925 19px 1px,#6e3718 0 2px,#6f3d26 1px 2px,#562e26 2px 2px,#53232f 3px 2px,#8b3f63 4px 2px,#c8679c 5px 2px,#921f5a 6px 2px,#9d1859 7px 2px,#a60f56 8px 2px,#ac0650 9px 2px,#b7054f 10px 2px,#c70f57 11px 2px,#cb1256 12px 2px,#ff548c 13px 2px,#b52348 14px 2px,#8d0414 15px 2px,#950800 16px 2px,#b92e11 17px 2px,#f77043 18px 2px,#ff824c 19px 2px,#5a2d18 0 3px,#6a412f 1px 3px,#522d25 2px 3px,#5c2633 3px 3px,#ae4e7c 4px 3px,#bf4985 5px 3px,#b54172 6px 3px,#dc6390 7px 3px,#ff88b9 8px 3px,#bf3161 9px 3px,#c02857 10px 3px,#b31142 11px 3px,#c01647 12px 3px,#ff8dbc 13px 3px,#ffb1d4 14px 3px,#9d1f2d 15px 3px,#cd402f 16px 3px,#db4c24 17px 3px,#db541d 18px 3px,#c03e00 19px 3px,#62362b 0 4px,#5c3025 1px 4px,#7b4c42 2px 4px,#84434b 3px 4px,#a53e6d 4px 4px,#ea82b3 5px 4px,#ffd6e8 6px 4px,#ffd1d3 7px 4px,#e999a2 8px 4px,#f79aa5 9px 4px,#fc949f 10px 4px,#d45765 11px 4px,#c83045 12px 4px,#e34f67 13px 4px,#ffdced 14px 4px,#bf5557 15px 4px,#900c00 16px 4px,#ad2000 17px 4px,#d9541b 18px 4px,#db5b1a 19px 4px,#5d302a 0 5px,#63342c 1px 5px,#9f6d62 2px 5px,#9e5e5f 3px 5px,#761b3e 4px 5px,#ffaccd 5px 5px,#f2c9c7 6px 5px,#bc9f8f 7px 5px,#b28379 8px 5px,#c3847b 9px 5px,#d28478 10px 5px,#cd6b62 11px 5px,#c6484b 12px 5px,#a72c31 13px 5px,#ffbcbf 14px 5px,#ba635c 15px 5px,#9e3015 16px 5px,#e97248 17px 5px,#ff915c 18px 5px,#ce5c20 19px 5px,#63322b 0 6px,#65342d 1px 6px,#55231a 2px 6px,#7a4541 3px 6px,#62242f 4px 6px,#ffcbd3 5px 6px,#b5948b 6px 6px,#43291a 7px 6px,#745249 8px 6px,#b7857c 9px 6px,#d18a78 10px 6px,#b05a49 11px 6px,#a1433b 12px 6px,#771c17 13px 6px,#73261e 14px 6px,#c0786a 15px 6px,#9a4f38 16px 6px,#a55635 17px 6px,#9f471f 18px 6px,#be6336 19px 6px,#633329 0 7px,#5e2f25 1px 7px,#64382d 2px 7px,#ba9288 3px 7px,#be9991 4px 7px,#edcfc5 5px 7px,#9a8276 6px 7px,#e8d2c7 7px 7px,#2b120d 8px 7px,#815c53 9px 7px,#d39684 10px 7px,#bd7662 11px 7px,#6d2318 12px 7px,#631f16 13px 7px,#db9d8e 14px 7px,#dca591 15px 7px,#a06a52 16px 7px,#71381b 17px 7px,#884825 18px 7px,#c07c55 19px 7px,#704233 0 8px,#714739 1px 8px,#725142 2px 8px,#ccb1a0 3px 8px,#c0ab96 4px 8px,#d9c8b6 5px 8px,#d6c8bd 6px 8px,#efe2dc 7px 8px,#261714 8px 8px,#a78e89 9px 8px,#f1c3b4 10px 8px,#e6ae9d 11px 8px,#b2736c 12px 8px,#450c03 13px 8px,#f7cebc 14px 8px,#fcd7bd 15px 8px,#8c5d43 16px 8px,#7e482c 17px 8px,#8b5636 18px 8px,#9c6a47 19px 8px,#644330 0 9px,#684937 1px 9px,#5a3f2e 2px 9px,#96816e 3px 9px,#e1d1b8 4px 9px,#cbbca7 5px 9px,#cab8ae 6px 9px,#dec9c6 7px 9px,#efd7d3 8px 9px,#e7c6bf 9px 9px,#ddada1 10px 9px,#d89d8f 11px 9px,#e5a198 12px 9px,#ffc7bc 13px 9px,#ffd6c2 14px 9px,#fff1d8 15px 9px,#663922 16px 9px,#82543c 17px 9px,#865d41 18px 9px,#8b6447 19px 9px,#5a4b36 0 10px,#5a4935 1px 10px,#634c3a 2px 10px,#5e4833 3px 10px,#422c17 4px 10px,#795d4f 5px 10px,#c7a09b 6px 10px,#c59895 7px 10px,#af7d74 8px 10px,#965c50 9px 10px,#995047 10px 10px,#8a382d 11px 10px,#9e4034 12px 10px,#ac5647 13px 10px,#ffcab8 14px 10px,#582d1a 15px 10px,#6a4334 16px 10px,#6f4a3a 17px 10px,#785341 18px 10px,#6f4c38 19px 10px,#807966 0 11px,#78705d 1px 11px,#6b5a4a 2px 11px,#675445 3px 11px,#5c4938 4px 11px,#573d30 5px 11px,#89605c 6px 11px,#a7706d 7px 11px,#aa665b 8px 11px,#d38175 9px 11px,#cb6a63 10px 11px,#b14842 11px 11px,#b3493b 12px 11px,#d17664 13px 11px,#8e5440 14px 11px,#603725 15px 11px,#5f3b2f 16px 11px,#5a3930 17px 11px,#5e3e31 18px 11px,#59392c 19px 11px,#43392d 0 12px,#3c3228 1px 12px,#453b32 2px 12px,#4b4137 3px 12px,#4c4332 4px 12px,#4a3d2d 5px 12px,#412821 6px 12px,#84554f 7px 12px,#8c3e32 8px 12px,#9f372c 9px 12px,#ba3a37 10px 12px,#c44441 11px 12px,#d46a5c 12px 12px,#611400 13px 12px,#4d230b 14px 12px,#4a2f1a 15px 12px,#49291e 16px 12px,#49281f 17px 12px,#48271e 18px 12px,#4b2d22 19px 12px,#45372c 0 13px,#45382f 1px 13px,#4f423c 2px 13px,#51473e 3px 13px,#524b39 4px 13px,#4e4331 5px 13px,#725c51 6px 13px,#e0b4a9 7px 13px,#883527 8px 13px,#942218 9px 13px,#950b0b 10px 13px,#900a09 11px 13px,#83180e 12px 13px,#c57868 13px 13px,#552415 14px 13px,#492819 15px 13px,#573229 16px 13px,#553329 17px 13px,#502e24 18px 13px,#543429 19px 13px,#695648 0 14px,#645143 1px 14px,#604c43 2px 14px,#422e23 3px 14px,#4b3a2a 4px 14px,#231000 5px 14px,#fff8ea 6px 14px,#b18072 7px 14px,#8a382a 8px 14px,#cc6056 9px 14px,#aa292d 10px 14px,#890b0f 11px 14px,#700402 12px 14px,#751a17 13px 14px,#ffb6b9 14px 14px,#b07372 15px 14px,#5b2c22 16px 14px,#563023 17px 14px,#552f22 18px 14px,#5c362b 19px 14px,#665140 0 15px,#705a4c 1px 15px,#432b21 2px 15px,#41291f 3px 15px,#311b0e 4px 15px,#b99f92 5px 15px,#ffe0d2 6px 15px,#8b5a4b 7px 15px,#7a3526 8px 15px,#b15d53 9px 15px,#963637 10px 15px,#8c2c2e 11px 15px,#ffaaa9 12px 15px,#a14b4a 13px 15px,#cc777e 14px 15px,#9e5659 15px 15px,#8c5a53 16px 15px,#451d11 17px 15px,#4f271d 18px 15px,#4e261c 19px 15px,#66543e 0 16px,#645140 1px 16px,#4a332b 2px 16px,#301816 3px 16px,#442a2b 4px 16px,#fff1ee 5px 16px,#c89c8f 6px 16px,#693a2a 7px 16px,#c89c8f 8px 16px,#fff0e7 9px 16px,#ffe0dc 10px 16px,#fff3ed 11px 16px,#ffe1d7 12px 16px,#ad726a 13px 16px,#96504e 14px 16px,#b2716f 15px 16px,#a3736f 16px 16px,#a8837d 17px 16px,#ad8882 18px 16px,#9d7872 19px 16px,#313526 0 17px,#2d2f24 1px 17px,#212121 2px 17px,#120d13 3px 17px,#41343d 4px 17px,#9e8588 5px 17px,#bd9387 6px 17px,#c89b88 7px 17px,#7f5b4d 8px 17px,#e3c8bd 9px 17px,#fffbf1 10px 17px,#907a6f 11px 17px,#ba998a 12px 17px,#e5b5a7 13px 17px,#e7a79d 14px 17px,#e0a19a 15px 17px,#dcb0ad 16px 17px,#b18f8d 17px 17px,#c4a2a0 18px 17px,#e2c3c0 19px 17px,#739fa2 0 18px,#9ac5cb 1px 18px,#add3e0 2px 18px,#b6d3e3 3px 18px,#c2d4e2 4px 18px,#bab5bb 5px 18px,#937368 6px 18px,#e5b8a5 7px 18px,#7a4f3f 8px 18px,#613c2c 9px 18px,#b8988b 10px 18px,#502f1e 11px 18px,#966d59 12px 18px,#c08c77 13px 18px,#d1907e 14px 18px,#a5675a 15px 18px,#dcb3ad 16px 18px,#f3d6d2 17px 18px,#f2d6d2 18px 18px,#d3bab5 19px 18px,#93d3df 0 19px,#80becd 1px 19px,#71abbf 2px 19px,#7cacc2 3px 19px,#8baabc 4px 19px,#848b91 5px 19px,#9a7e73 6px 19px,#a47762 7px 19px,#aa7b6b 8px 19px,#c69b8a 9px 19px,#c9a293 10px 19px,#9d7764 11px 19px,#976a53 12px 19px,#9d674f 13px 19px,#c7856f 14px 19px,#d49687 15px 19px,#cda79e 16px 19px,#c8afaa 17px 19px,#c9b0ab 18px 19px,#b8a19b 19px 19px}
<div class="img"></div>

Beveled shadow border

I am trying to do a beveled shadow border in CSS.
Now it works that i have a several images (up left corner, down left, right corner etc...). It is very bad solution of this problem and I beleive a better solution in CSS or JS is possible.
With buttons it doesnt work.
The most important thing, it has to be responsive
In css I tried outset, but it does not work exactly how I want.
EXAMPLE IN IMAGE: example how it should looks like
You can do this with multiple box-shadow properties, for example:
box-shadow:
-1px 1px 0px #ccc,
-2px 2px 0px #ccc,
-3px 3px 0px #ccc,
-4px 4px 0px #ccc,
-5px 5px 0px #ccc,
-6px 6px 0px #ccc,
-7px 7px 0px #ccc,
-8px 8px 0px #ccc,
-9px 9px 0px #ccc,
-10px 10px 0px #ccc
}
Demo example - https://jsfiddle.net/bztexp0z/
body { background-color:#28434E; padding:50px; }
.box {
width:100px;
height:100px;
background-color:#fff;
box-shadow:
-1px 1px 0px #ccc,
-2px 2px 0px #ccc,
-3px 3px 0px #ccc,
-4px 4px 0px #ccc,
-5px 5px 0px #ccc,
-6px 6px 0px #ccc,
-7px 7px 0px #ccc,
-8px 8px 0px #ccc,
-9px 9px 0px #ccc,
-10px 10px 0px #ccc
}
<div class="box">
</div>
You can reduce the thickness by just having -1 to -4 for example.
Finally I work this out. I used pseudo selector :before and :after with skew transformation.
Solution is here: https://gist.github.com/rihot/d4530492dfdbec05db1421fce1d248e6

I have a blinking box, how can I add a gradient to this or program it easier?

I was trying to figure out how to get a blinking box, and as I did not really find a solution on the net, I was fiddling around a bit.
I came up with the following, this works fine in general. My question is simply a) if there is an easier way to do this, and b) if I can program it in a way that it increases / decreases by gradient, instead of me having to program so many classes and stuff like that.
See this code in action: http://jsfiddle.net/ZUJ5b/7/
html
<div id="test" class="test">Hello</div>
jQuery
$(document).ready(function () {
setInterval(blink, 75);
});
function blink() {
if ($('#test').hasClass("test")) {
$("#test").removeClass('test').addClass('test1');
} else if($('#test').hasClass("test1")) {
$("#test").removeClass('test1').addClass('test2');
} else if($('#test').hasClass("test2")) {
$("#test").removeClass('test2').addClass('test3');
} else if($('#test').hasClass("test3")) {
$("#test").removeClass('test3').addClass('test5');
} else if($('#test').hasClass("test4")) {
$("#test").removeClass('test4').addClass('test5');
} else if($('#test').hasClass("test5")) {
$("#test").removeClass('test5').addClass('test6');
} else if($('#test').hasClass("test6")) {
$("#test").removeClass('test6').addClass('test7');
} else {
$("#test").removeClass('test7').addClass('test');
}
}
CSS
.test {
padding: 20px;
width: 100px;
border: 1px #ED0 outset;
box-shadow: 0px 0px 6px 1px #FE4;
-moz-box-shadow: 0px 0px 6px 1px #FE4;
-webkit-box-shadow: 0px 0px 6px 1px #FE4;
}
.test1 {
padding: 20px;
width: 100px;
border: 1px #EED000 outset;
box-shadow: 0px 0px 6px 1px #FFE544;
-moz-box-shadow: 0px 0px 6px 1px #FFE544;
-webkit-box-shadow: 0px 0px 6px 1px #FFE544;
}
.test2 {
padding: 20px;
width: 100px;
border: 1px #EEC300 outset;
box-shadow: 0px 0px 7px 2px #FFDD44;
-moz-box-shadow: 0px 0px 7px 2px #FFDD44;
-webkit-box-shadow: 0px 0px 7px 2px #FFDD44;
}
.test3 {
padding: 20px;
width: 100px;
border: 1px #EEB600 outset;
box-shadow: 0px 0px 7px 2px #FFD444;
-moz-box-shadow: 0px 0px 7px 2px #FFD444;
-webkit-box-shadow: 0px 0px 7px 2px #FFD444;
}
.test4 {
padding: 20px;
width: 100px;
border: 1px #EA0 outset;
box-shadow: 0px 0px 8px 3px #FFCC44;
-moz-box-shadow: 0px 0px 8px 3px #FFCC44;
-webkit-box-shadow: 0px 0px 8px 3px #FFCC44;
}
.test5 {
padding: 20px;
width: 100px;
border: 1px #EEB600 outset;
box-shadow: 0px 0px 7px 2px #FFD444;
-moz-box-shadow: 0px 0px 7px 2px #FFD444;
-webkit-box-shadow: 0px 0px 7px 2px #FFD444;
}
.test6 {
padding: 20px;
width: 100px;
border: 1px #EEC300 outset;
box-shadow: 0px 0px 7px 2px #FFDD44;
-moz-box-shadow: 0px 0px 7px 2px #FFDD44;
-webkit-box-shadow: 0px 0px 7px 2px #FFDD44;
}
.test7 {
padding: 20px;
width: 100px;
border: 1px #EED000 outset;
box-shadow: 0px 0px 6px 1px #FFE544;
-moz-box-shadow: 0px 0px 3px 1px #FFE544;
-webkit-box-shadow: 0px 0px 3px 1px #FFE544;
}
Wow! You're dedicated! There are much easier ways to animate with css. Check out CSS transitions (https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_transitions)
It is pretty easy with css transitions (but only for new versions of browser)
Here is demo fiddle
Just add a transition property to your css class and in that define on which property you want to put transition on (in your case border shadow) and also define for how much time you want to make the transition.
transition: box-shadow 1s;

Thick text outline

I need to add a thick outline to text. I found this trick
text-shadow:
-1px -1px 0 #00f,
1px -1px 0 #00f,
-1px 1px 0 #00f,
1px 1px 0 #00f;
But it only works for 1px outline. The outline is also not very smooth, on a big fonts it appears broken. Is there a way to make a thicker smooth outline of 2 or 3px? CSS or JS or jQuery plugins, anything would be helpful
EDIT: You have to use all of the permutations, including ones like -1px 3px 0px #00f or 3px -2px 0px #00f.
text-shadow:
-1px -1px 0 #00f,
1px -1px 0 #00f,
-1px 1px 0 #00f,
1px 1px 0 #00f,
-2px -2px 0 #00f,
2px -2px 0 #00f,
-2px 2px 0 #00f,
2px 2px 0 #00f,
-3px -3px 0 #00f,
3px -3px 0 #00f,
-3px 3px 0 #00f,
3px 3px 0 #00f;

How can I display a 'Reload' symbol in HTML without loading an image via HTTP?

I would like to display a 'refresh' symbol in an HTML/JavaScript app I'm creating, but I do not want to make any HTTP requests to load an image. How can I do this reliably across all major browsers?
The closest Unicode value I could find is: ↺ (↺), but the arrow is pointing the wrong way.
Is there another Unicode value that works?
Is there a Webdings font that works? (They don't usually work in Opera and Firefox.)
Is there a way to create an image in JavaScript using a base64 image source provided by a String from that JS?
EDIT:
The reason for this is NOT overhead. The app being created must be self-contained in a single javascript file, without any other dependencies. It is a development utility that can be added to any project, without the need for a network.
If you find the character ↻ (↻), i.e. U+21BB CLOCKWISE OPEN CIRCLE ARROW, acceptable for your needs (its arrow might not be placed the same way as in common reload icons), then you can use it rather safely:
.reload {
font-family: Lucida Sans Unicode
}
<span class=reload>↻</span>
The Lucida Sans Unicode font contains the symbol, and it is available in virtually any Windows system you can find these days. According to MS info, it was included even in Windows 98 (and Windows 95 plus).
Systems other than Windows can reasonably be expected to have the symbol in some font and to have browsers that know how to pick it up from some of them. And fonts containing it have rather similar shapes for it. (But if the symbol needs to match stylistically the text of your document, you need to study the situation in more detail and try to make sure that all fonts in your font list, or “font stack”, contain it.)
Unicode Character
There are at least two Unicode characters that might serve as Refresh or Reload icons:
CLOCKWISE GAPPED CIRCLE ARROWU+27F3⟳
CLOCKWISE OPEN CIRCLE ARROWU+21BB↻
The first does not appear in iOS 7 or 8 or 9 in either Safari or Chrome. So given that, and given the answer by Paul D. White, I recommend using the second one, CLOCKWISE OPEN CIRCLE ARROW.
Tip: If you are a Mac user, obtain the free-of-cost app UnicodeChecker. You can search for characters by name, and you can see a list of fonts (on your particular Mac) containing a glyph for that character.
Icon Font
Some fonts have been created with scalable vector-based icons in place of regular character glyphs.
Font Awesome, see: fa-repeat
Vaadin Font Icons
If the browser supports loading image data from a Base64 string, you can use img and set its src to the following format:
data:[<mediatype>][;base64],<data>
Example:
var img = document.getElementById("yourImage");
img.src = "data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7";
<img id="yourImage" />
The clockwise equivalent to your Unicode character is ↻, ↻ (although, as David C. Bishop notes in the comments, Chromebooks use #27f2, ⟳).
Using a text character is an option, but Windows XP might not display the character (depending on the character you use, and the font you display it in). #Jukka K. Korpela notes that this character is included in the Lucida Sans Unicode font, so it should work fine even in Windows XP.
As far as Wingdings fonts go, to avoid an HTTP request you’d need to be confident that the font in question in going to be installed on end user’s computers. I don’t think there’s a common cross-platform Wingdings font (I could be entirely wrong though).
You can indeed create an image from a string that contains the base64-encoded representation of the image using JavaScript. You could do so like this:
var image = new Image();
image.src = 'data:image/gif;base64,' + BASE64_ENCODED_STRING; // Replace gif with whatever image format it actually is
The data-uri might not work great in Internet Explorer 8 and earlier though, which Windows XP users may be stuck on. (And you don’t actually need JavaScript for this: you can just put an <img> tag in your page with that src attribute.)
.refresh {
display: inline-block;
transform: rotate(90deg);
}
<span>↻</span>
<hr>
<span class="refresh">↻</span>
Unicode 6 Character
'CLOCKWISE DOWNWARDS AND UPWARDS OPEN CIRCLE ARROWS' (U+1F503) 🔃
Sadly font support for the glyph is not the best, so "all major browsers" might be a stretch... :-/
You mention "all major browsers", so let’s assume that:
not everyone have javascript
not everyone can embed fonts (blackberry etc)
not everyone supports all UNCODE representations (windows XP)
not everyone supports inline data uri’s (IE7-)
So what’s left? I would suggest a HTML1-compliant IMG element, that will also be cached after first load:
<img src="/refresh.gif" alt="refresh">
It will work in every single browser I know of, except LYNX and other pure text-based browsers. But they will show "refresh" instead, so that’s fine.
If you really want to avoid that extra 2bytes request for "modern" browsers, you can use conditional comments for IE7-:
<!--[if lte IE 7]>
<img src="refresh.gif" alt="refresh">
<![endif]-->
And something like this for the rest:
<img src="data:image/gif;base64,..." alt="refresh">
If you’re up to something new for the newest, you can use CSS box shadows (demo):
.refresh{
border-radius: 0;
display: inline-block;
width: 1px;
height: 1px;
box-shadow: 0px 0px rgba(0,0,0,0),0px 1px rgba(0,0,0,0),0px 2px rgba(0,0,0,0),0px 3px rgba(0,0,0,0),0px 4px rgba(0,0,0,0),0px 5px rgba(0,0,0,0),0px 6px rgba(0,0,0,0),0px 7px rgba(0,0,0,0),0px 8px rgba(0,0,0,0),0px 9px rgba(0,0,0,0),0px 10px rgba(0,0,0,0),0px 11px rgba(0,0,0,0),0px 12px rgba(0,0,0,0),0px 13px rgba(0,0,0,0),0px 14px rgba(0,0,0,0),0px 15px rgba(0,0,0,0),1px 0px rgba(0,0,0,0),1px 1px rgba(0,0,0,0),1px 2px rgba(0,0,0,0),1px 3px rgba(0,0,0,0),1px 4px rgba(0,0,0,0),1px 5px rgba(0,0,0,0),1px 6px rgba(0,0,0,0),1px 7px rgba(0,0,0,0),1px 8px rgba(0,0,0,0),1px 9px rgba(0,0,0,0),1px 10px rgba(0,0,0,0),1px 11px rgba(0,0,0,0),1px 12px rgba(0,0,0,0),1px 13px rgba(0,0,0,0),1px 14px rgba(0,0,0,0),1px 15px rgba(0,0,0,0),2px 0px rgba(0,0,0,0),2px 1px rgba(0,0,0,0),2px 2px rgba(0,0,0,0),2px 3px rgba(0,0,0,0),2px 4px rgba(0,0,0,0),2px 5px rgba(0,0,0,0.06),2px 6px rgba(0,0,0,0.55),2px 7px rgba(0,0,0,0.79),2px 8px rgba(0,0,0,0.86),2px 9px rgba(0,0,0,0.86),2px 10px rgba(0,0,0,0.65),2px 11px rgba(0,0,0,0.31),2px 12px rgba(0,0,0,0),2px 13px rgba(0,0,0,0),2px 14px rgba(0,0,0,0),2px 15px rgba(0,0,0,0),3px 0px rgba(0,0,0,0),3px 1px rgba(0,0,0,0),3px 2px rgba(0,0,0,0),3px 3px rgba(0,0,0,0),3px 4px rgba(0,0,0,0.25),3px 5px rgba(0,0,0,0.83),3px 6px rgba(0,0,0,0.86),3px 7px rgba(0,0,0,0.83),3px 8px rgba(0,0,0,0.69),3px 9px rgba(0,0,0,0.74),3px 10px rgba(0,0,0,0.86),3px 11px rgba(0,0,0,0.86),3px 12px rgba(0,0,0,0.6),3px 13px rgba(0,0,0,0.06),3px 14px rgba(0,0,0,0),3px 15px rgba(0,0,0,0),4px 0px rgba(0,0,0,0),4px 1px rgba(0,0,0,0),4px 2px rgba(0,0,0,0),4px 3px rgba(0,0,0,0.25),4px 4px rgba(0,0,0,0.83),4px 5px rgba(0,0,0,0.83),4px 6px rgba(0,0,0,0.43),4px 7px rgba(0,0,0,0),4px 8px rgba(0,0,0,0),4px 9px rgba(0,0,0,0),4px 10px rgba(0,0,0,0.13),4px 11px rgba(0,0,0,0.69),4px 12px rgba(0,0,0,0.86),4px 13px rgba(0,0,0,0.6),4px 14px rgba(0,0,0,0),4px 15px rgba(0,0,0,0),5px 0px rgba(0,0,0,0),5px 1px rgba(0,0,0,0),5px 2px rgba(0,0,0,0),5px 3px rgba(0,0,0,0.69),5px 4px rgba(0,0,0,0.86),5px 5px rgba(0,0,0,0.25),5px 6px rgba(0,0,0,0),5px 7px rgba(0,0,0,0),5px 8px rgba(0,0,0,0),5px 9px rgba(0,0,0,0),5px 10px rgba(0,0,0,0),5px 11px rgba(0,0,0,0),5px 12px rgba(0,0,0,0.69),5px 13px rgba(0,0,0,0.86),5px 14px rgba(0,0,0,0.25),5px 15px rgba(0,0,0,0),6px 0px rgba(0,0,0,0),6px 1px rgba(0,0,0,0),6px 2px rgba(0,0,0,0.13),6px 3px rgba(0,0,0,0.86),6px 4px rgba(0,0,0,0.6),6px 5px rgba(0,0,0,0),6px 6px rgba(0,0,0,0),6px 7px rgba(0,0,0,0),6px 8px rgba(0,0,0,0),6px 9px rgba(0,0,0,0),6px 10px rgba(0,0,0,0),6px 11px rgba(0,0,0,0),6px 12px rgba(0,0,0,0.13),6px 13px rgba(0,0,0,0.86),6px 14px rgba(0,0,0,0.65),6px 15px rgba(0,0,0,0),7px 0px rgba(0,0,0,0),7px 1px rgba(0,0,0,0),7px 2px rgba(0,0,0,0.43),7px 3px rgba(0,0,0,0.86),7px 4px rgba(0,0,0,0.31),7px 5px rgba(0,0,0,0),7px 6px rgba(0,0,0,0),7px 7px rgba(0,0,0,0),7px 8px rgba(0,0,0,0),7px 9px rgba(0,0,0,0),7px 10px rgba(0,0,0,0),7px 11px rgba(0,0,0,0),7px 12px rgba(0,0,0,0),7px 13px rgba(0,0,0,0.75),7px 14px rgba(0,0,0,0.83),7px 15px rgba(0,0,0,0),8px 0px rgba(0,0,0,0),8px 1px rgba(0,0,0,0.43),8px 2px rgba(0,0,0,0.69),8px 3px rgba(0,0,0,0.86),8px 4px rgba(0,0,0,0.6),8px 5px rgba(0,0,0,0.31),8px 6px rgba(0,0,0,0),8px 7px rgba(0,0,0,0),8px 8px rgba(0,0,0,0),8px 9px rgba(0,0,0,0),8px 10px rgba(0,0,0,0),8px 11px rgba(0,0,0,0),8px 12px rgba(0,0,0,0),8px 13px rgba(0,0,0,0.69),8px 14px rgba(0,0,0,0.86),8px 15px rgba(0,0,0,0),9px 0px rgba(0,0,0,0),9px 1px rgba(0,0,0,0.48),9px 2px rgba(0,0,0,0.86),9px 3px rgba(0,0,0,0.86),9px 4px rgba(0,0,0,0.86),9px 5px rgba(0,0,0,0.13),9px 6px rgba(0,0,0,0),9px 7px rgba(0,0,0,0),9px 8px rgba(0,0,0,0),9px 9px rgba(0,0,0,0),9px 10px rgba(0,0,0,0),9px 11px rgba(0,0,0,0),9px 12px rgba(0,0,0,0),9px 13px rgba(0,0,0,0.75),9px 14px rgba(0,0,0,0.83),9px 15px rgba(0,0,0,0),10px 0px rgba(0,0,0,0),10px 1px rgba(0,0,0,0),10px 2px rgba(0,0,0,0.79),10px 3px rgba(0,0,0,0.86),10px 4px rgba(0,0,0,0.6),10px 5px rgba(0,0,0,0),10px 6px rgba(0,0,0,0),10px 7px rgba(0,0,0,0),10px 8px rgba(0,0,0,0),10px 9px rgba(0,0,0,0),10px 10px rgba(0,0,0,0),10px 11px rgba(0,0,0,0),10px 12px rgba(0,0,0,0.13),10px 13px rgba(0,0,0,0.86),10px 14px rgba(0,0,0,0.65),10px 15px rgba(0,0,0,0),11px 0px rgba(0,0,0,0),11px 1px rgba(0,0,0,0),11px 2px rgba(0,0,0,0.38),11px 3px rgba(0,0,0,0.83),11px 4px rgba(0,0,0,0.06),11px 5px rgba(0,0,0,0),11px 6px rgba(0,0,0,0),11px 7px rgba(0,0,0,0),11px 8px rgba(0,0,0,0),11px 9px rgba(0,0,0,0),11px 10px rgba(0,0,0,0),11px 11px rgba(0,0,0,0),11px 12px rgba(0,0,0,0.69),11px 13px rgba(0,0,0,0.86),11px 14px rgba(0,0,0,0.25),11px 15px rgba(0,0,0,0),12px 0px rgba(0,0,0,0),12px 1px rgba(0,0,0,0),12px 2px rgba(0,0,0,0),12px 3px rgba(0,0,0,0.31),12px 4px rgba(0,0,0,0),12px 5px rgba(0,0,0,0),12px 6px rgba(0,0,0,0.25),12px 7px rgba(0,0,0,0),12px 8px rgba(0,0,0,0),12px 9px rgba(0,0,0,0),12px 10px rgba(0,0,0,0.13),12px 11px rgba(0,0,0,0.69),12px 12px rgba(0,0,0,0.86),12px 13px rgba(0,0,0,0.6),12px 14px rgba(0,0,0,0),12px 15px rgba(0,0,0,0),13px 0px rgba(0,0,0,0),13px 1px rgba(0,0,0,0),13px 2px rgba(0,0,0,0),13px 3px rgba(0,0,0,0),13px 4px rgba(0,0,0,0),13px 5px rgba(0,0,0,0.06),13px 6px rgba(0,0,0,0.83),13px 7px rgba(0,0,0,0.83),13px 8px rgba(0,0,0,0.69),13px 9px rgba(0,0,0,0.75),13px 10px rgba(0,0,0,0.86),13px 11px rgba(0,0,0,0.86),13px 12px rgba(0,0,0,0.6),13px 13px rgba(0,0,0,0.06),13px 14px rgba(0,0,0,0),13px 15px rgba(0,0,0,0),14px 0px rgba(0,0,0,0),14px 1px rgba(0,0,0,0),14px 2px rgba(0,0,0,0),14px 3px rgba(0,0,0,0),14px 4px rgba(0,0,0,0),14px 5px rgba(0,0,0,0.13),14px 6px rgba(0,0,0,0.55),14px 7px rgba(0,0,0,0.79),14px 8px rgba(0,0,0,0.86),14px 9px rgba(0,0,0,0.86),14px 10px rgba(0,0,0,0.65),14px 11px rgba(0,0,0,0.31),14px 12px rgba(0,0,0,0),14px 13px rgba(0,0,0,0),14px 14px rgba(0,0,0,0),14px 15px rgba(0,0,0,0),15px 0px rgba(0,0,0,0),15px 1px rgba(0,0,0,0),15px 2px rgba(0,0,0,0),15px 3px rgba(0,0,0,0),15px 4px rgba(0,0,0,0),15px 5px rgba(0,0,0,0),15px 6px rgba(0,0,0,0),15px 7px rgba(0,0,0,0),15px 8px rgba(0,0,0,0),15px 9px rgba(0,0,0,0),15px 10px rgba(0,0,0,0),15px 11px rgba(0,0,0,0),15px 12px rgba(0,0,0,0),15px 13px rgba(0,0,0,0),15px 14px rgba(0,0,0,0),15px 15px rgba(0,0,0,0);
}
I think this icon will be helpful to you.
🗘
Encodings
- HTML Entity (decimal) 🗘
- HTML Entity (hex) 🗘

Categories

Resources