Logo

dev-resources.site

for different kinds of informations.

Generate Right Big Arrow 👲 with CSS for Local Webview

Published at
3/5/2021
Categories
android
webview
css
arrow
Author
madrafj
Categories
4 categories in total
android
open
webview
open
css
open
arrow
open
Author
7 person written this
madrafj
open
Generate Right Big Arrow 👲 with CSS for Local Webview

Skip to CodePen

We can insert most of unicode symbols to a website just by copy paste it to our code. Another way is to embed a certain syntax following with UTF code of that symbol. For example to insert this β™  we can embed ♠ in HTML or '\u2660' in javascript.

Unfortunately, when I tried to embed this arrow 👲 to my Android WebView, it didn't work. But many other symbols worked well.

Recently, I knew this happened because of the font of that symbol is outside of Android scope. I found several suggestions on forum discussion to solve it, such as adding a necessary font to your App or using third-party CSS-icon. The first one wastes memory cause it consumed at least 1MB to add font to App in exchange for adding one symbol. The second option is more reasonable, we can implement it by adding resource-link from CDN to our HTML (for using it online) or by importing it as node module (for using it offline).

But, I found a better solution,

1. Using CSS Border-hacks

/* create this: ∟ */
.next {
  position: relative;
  width: 20px;
  height: 20px;
  border-bottom: 2px solid black;
  border-left: 2px solid black;
}

/* add Diagonal line: ∟ + βŸ‹ = βŸ€ */
.next:after {
  content: "";
  position: absolute;
  bottom: -2px;          /* minus border-width */
  left: -1px;            /* minus half-border-width */
  border-bottom: 2px solid black;
  width: 28px;           /* about 1.4x .next-width */   
  transform: rotate(-45deg);
  transform-origin: 0 0;
}
Enter fullscreen mode Exit fullscreen mode

For better aligning purpose use only even number border-width. See comment in code above.

Next, add transform property to .next class to rotate arrow 135deg clockwise,

.next {
  ...
  transform: rotate(-135deg);
}
...
Enter fullscreen mode Exit fullscreen mode

2. A Simpler Solution

Here's a more simple solution by adding math-symbol called Three Dimensional Angel β€œβŸ€β€ (U+27C0), reference about this symbol Click Here.

Then, simply rotate it so it headed rightward.

Here's some contras of two solutions above:

  1. CSS Border-Hacks
    • You must add more padding to parent element such as button, because the parent only considers the initial size (before transformation) which is smaller.
    • Compared to second solution, the CSS configuration is indeed longer and more complex.
  2. 3Dimensional-Angle Based
    • The symbol is too small, cause the actual initial size (before transformation) is just as tall as lowercase character.
    • The parent element only considers the line-height of initial size (not an actual size) so it will expand the parent size more than it should be. Suggestion: Make parent size smaller and add negative margin to wrapper element for alignment.


Conclusion

  • The second solution is more simple and with some practices it will become handy.
  • The first solution is good for practices, and you will gain basic for creating other symbols or shapes from just borders. Check this reference

Thanks for coming.

webview Article's
30 articles in total
Favicon
A New Era of Cross-Platform Desktop Application Development in Go Language: A Comprehensive Analysis of LCL, CEF, and Webview
Favicon
Building Document PDF Scanner for Windows, Android and iOS with .NET MAUI Blazor
Favicon
Webview em QML (Qt Modeling Language)
Favicon
Switching from .NET MAUI Blazor to WebView Control for Document Scanning
Favicon
Developing a Desktop Document Scanner Application with .NET MAUI Blazor
Favicon
Is there any fix in react native which I can apply for upi payment using react-native-webview?
Favicon
Notification List - inbox list Webview
Favicon
Android WebView: Handle special Intent URI requests
Favicon
Chrome extensions in WebView2, CefSharp, and DotNetBrowser
Favicon
It is possible to build a full-featured browser using react-native.
Favicon
React Native WebView: Make Android pullToRefresh work without any glitches
Favicon
8 Tips for Creating a Native Look and Feel in Tauri Applications
Favicon
How to Add CanvasJS Charts to your Android App?
Favicon
WebView Callback response in Flutter
Favicon
What is a WebView And How To Test It?
Favicon
Aplikasi WebView Pro (Convert Web ke Apk)
Favicon
Creating a GO GUI with Alpine.js and Webview
Favicon
WKWebView persistent cookies open source solution and other useful things for WKWebView
Favicon
Download PDF files to device storage with React Native Webview
Favicon
Fix: physical keyboard can't type in Flutter's Webview
Favicon
ERR_CLEARTEXT_NOT_PERMITTED from Android WebView
Favicon
Append a new User-Agent to WebView in Android
Favicon
Which Embed Browser engine to use?
Favicon
Interaction between Vue JS Webview and native Apps
Favicon
Flutter둜 μ›Ήμ•± λ§Œλ“€λ©° μ§„ν–‰ν–ˆλ˜ 정리 (1)
Favicon
Generate Right Big Arrow 👲 with CSS for Local Webview
Favicon
VsCode extension using webview and message posting
Favicon
React Native WebView debugging
Favicon
Proton Native
Favicon
WebView Apps on your OS

Featured ones: