question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Icon not centered on mobile

See original GitHub issue

Icon looks centered on desktop but is pushed to the right on mobile (iPhone X)

Screen Shot 2020-03-29 at 12 25 33 AM

const ezButton = L.easyButton('<span style="font-size:2em; line-height:26px; color:#FF3D2D;">&hearts;</span>', function (btn, map) {
})

Any ideas how to fix?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
kitchensjncommented, Apr 30, 2020

I’m probably late to this thread but just had to work through this myself:

const ezButton = L.easyButton(
    '<span style="font-size:2em; line-height:26px; color:#FF3D2D;">&hearts;</span>', 
    function (btn, map) {}
)
ezButton.button.style.padding = '0px';

This will remove the padding and allow your icon to be centered within the button. There may be a more elegant way of changing the button style when you initially create it. Hope this helps get you on the right track!

1reaction
sonfire186commented, May 24, 2020

https://github.com/CliffCloud/Leaflet.EasyButton/issues/48

function _fixEasyButtonSize(button) {
    var buttonElement = button.button;
    buttonElement.style.padding = '0px';
    buttonElement.style.width = "26px";
    buttonElement.style.height = "26px";
    buttonElement.style.minWidth = "26px";
    buttonElement.style.minHeight = "26px";
}
_fixEasyButtonSize(button);
Read more comments on GitHub >

github_iconTop Results From Across the Web

icon inside button not centered in iphone - css - Stack Overflow
I would use this trick to center it horizontally and vertically. (Last example on the page). button { width: 40px; height: 40px; ...
Read more >
Horizontal bottom-docked icons are not centered on mobile ...
Horizontal bottom-docked icons are not centered on mobile device ... For some reason, the horizontal bottom-docked share icons are stuck in left-alignment. Is ......
Read more >
Icons not centering on Mobile - BB Theme
Hi Elizabeth,. The reason this is happening is that the media query you mentioned above is setting the alignment on devices with a...
Read more >
Mobile version isn't centered? : r/elementor - Reddit
It's probably overflow. In the section settings, of the section that's overflowing from its container, you can select overflow: hidden.
Read more >
Center align icons in mobile view - Customize with code
When you're on a mobile that has width of less than 350px the icons are bigger than the screen. They are also off...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found