{"id":1935,"date":"2022-08-17T16:19:10","date_gmt":"2022-08-17T16:19:10","guid":{"rendered":"https:\/\/www.antpace.com\/blog\/?p=1935"},"modified":"2025-08-25T17:59:25","modified_gmt":"2025-08-25T17:59:25","slug":"debug-mobile-css-on-android-chrome","status":"publish","type":"post","link":"https:\/\/www.antpace.com\/blog\/debug-mobile-css-on-android-chrome\/","title":{"rendered":"Debugging Mobile CSS on Chrome for Android"},"content":{"rendered":"<p>On this website (this very one you are reading) I have <a href=\"https:\/\/www.antpace.com\/resume\/\" target=\"_blank\" rel=\"noopener\">a resume page<\/a>. On it, I display a timeline styled with CSS. I use the <code>border-radius<\/code> property to create circles for the years on that timeline. The years connect between &lt;div&gt; elements that represent my work experience.<\/p>\n<figure id=\"attachment_1936\" aria-describedby=\"caption-attachment-1936\" style=\"width: 1083px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1936\" src=\"https:\/\/www.antpace.com\/blog\/wp-content\/uploads\/2023\/08\/resume-timeline.png\" alt=\"timeline displayed on a resume webpage\" width=\"1083\" height=\"881\" \/><figcaption id=\"caption-attachment-1936\" class=\"wp-caption-text\">An image can be worth a forty-two words<\/figcaption><\/figure>\n<p>It looks great (at least,\u00a0 I think so). Except on mobile. Specifically, on Android running Chrome. The circle appears oblongly squished.<\/p>\n<figure id=\"attachment_1937\" aria-describedby=\"caption-attachment-1937\" style=\"width: 1080px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1937\" src=\"https:\/\/www.antpace.com\/blog\/wp-content\/uploads\/2023\/08\/resume-circles-on-android.jpg\" alt=\"Broken CSS on Android\" width=\"1080\" height=\"2400\" \/><figcaption id=\"caption-attachment-1937\" class=\"wp-caption-text\">Broken CSS on Android<\/figcaption><\/figure>\n<p>I could not recreate this bug on my laptop, even when I used Chrome Developer Tools to simulate mobile. Not being able to reproduce a bug consistently is a very frustrating experience.<\/p>\n<figure id=\"attachment_1938\" aria-describedby=\"caption-attachment-1938\" style=\"width: 952px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1938\" src=\"https:\/\/www.antpace.com\/blog\/wp-content\/uploads\/2023\/08\/chrome-desktop-inspector.png\" alt=\"Chrome developer tools\" width=\"952\" height=\"649\" \/><figcaption id=\"caption-attachment-1938\" class=\"wp-caption-text\">I couldn&#8217;t recreate the mobile bug on my laptop. <em>*Sigh*<\/em><\/figcaption><\/figure>\n<h2>USB debugging<\/h2>\n<p>I would have to use remote debugging via Chrome DevTools. The <strong>first step<\/strong> was to enable &#8220;Developer Options&#8221; on my Android device. I was using a S21 Galaxy Ultra. On this device I navigated to &#8220;Settings&#8221; -&gt; &#8220;About Phone&#8221; -&gt; &#8220;Software information&#8221;. Then I triple tapped the &#8220;Build number&#8221; and received a toast message &#8220;Developer mode activated&#8221;. This feels familiar, as it has been a similar process on previous Android devices that I have owned. I&#8217;d post a picture of my software information screen, but am worried that some of the data could be used maliciously by strangers on the internet.<\/p>\n<p>&#8220;Developer options&#8221; was revealed in my &#8220;Settings&#8221; app. From there, I could turn on &#8220;USB debugging&#8221;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1939\" src=\"https:\/\/www.antpace.com\/blog\/wp-content\/uploads\/2023\/08\/usb-debugging.jpg\" alt=\"usb debugging in the developer options menu\" width=\"1080\" height=\"2400\" \/><\/p>\n<p>Now, I could connect my Android to my MacBook. From my MacBook, I opened Chrome and navigated to <code>chrome:\/\/inspect\/#devices<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1940\" src=\"https:\/\/www.antpace.com\/blog\/wp-content\/uploads\/2023\/08\/chrome-inspect-devices.png\" alt=\"view usb connected devices running chrome\" width=\"800\" height=\"382\" \/><\/p>\n<p>As long as my Android also had Chrome running, I could see my device listed with any open browser tabs. Clicking &#8220;inspect&#8221; opened a new window on my laptop that mirrored my cellphone&#8217;s screen. When I scrolled on one, it reflected on the other.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1941\" src=\"https:\/\/www.antpace.com\/blog\/wp-content\/uploads\/2023\/08\/mobile-inspect.png\" alt=\"Inspect mobile device from desktop\" width=\"996\" height=\"643\" \/><\/p>\n<h2>CSS Solution<\/h2>\n<p>I could inspect elements from the developer tools panel. This was exactly what I needed to debug the problem. And, the fix ended up being pretty easy. Here&#8217;s the original, relevant CSS:<\/p>\n<pre>.timeline .year {\n  font-size: 1em;\n  line-height: 4;\n  border-radius: 50%;\n  width: 6em;\n}\n<\/pre>\n<p>The issue was ultimately with the width and height properties. The circles look correct on my desktop browser because the width and height rendered to nearly identical &#8211; 64px by 66px. To get a circle with CSS you need an element with the same height and width (the greater the difference, the less even and more stretched the circle appears), and then set the border-radius to 50%. On Android, that same element was being rendered as 64px by 85px. This was most probably happening because the height was not being explicitly defined.<\/p>\n<p>As a remedy, I hard-coded the width and height properties. I changed the unit of measurement to pixels for both.<\/p>\n<pre>.timeline .year {\n  font-size: 1em;\n  line-height: 4;\n  border-radius: 50%;\n  width: 65px;\n  height: 65px;\n}\n<\/pre>\n<p>This fixed the circle from being stretched. But, now the text was not centered that way that it should be.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1942\" src=\"https:\/\/www.antpace.com\/blog\/wp-content\/uploads\/2023\/08\/fixed-circle.png\" alt=\"Fixed CSS displays a circle\" width=\"850\" height=\"705\" \/><\/p>\n<p>That was happening because of the <code>line-height<\/code> property. Since it was set without a unit of measure, most browsers would interpret it to mean a multiplier of the current font-size. And, the font-size was also using a relative unit of measure, <code>em<\/code>. Right away, that was a code smell. It was a browser issue, where along the way values were not being calculated as expected.<\/p>\n<p>On mobile, the font-size was being calculated to 20.8px. On desktop, the font-was was being calculated to 16px. I fixed this by changing the line-height value to an absolute unit of measure:<\/p>\n<pre>.timeline .year {\n  font-size: 1em;\n  line-height: 65px;\n  border-radius: 50%;\n  width: 65px;\n  height: 65px;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>On this website (this very one you are reading) I have a resume page. On it, I display a timeline styled with CSS. I use the border-radius property to create circles for the years on that timeline. The years connect between &lt;div&gt; elements that represent my work experience. It looks great (at least,\u00a0 I think &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.antpace.com\/blog\/debug-mobile-css-on-android-chrome\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Debugging Mobile CSS on Chrome for Android&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":3249,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[33,55],"class_list":["post-1935","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-development","tag-css","tag-frontend"],"_links":{"self":[{"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/posts\/1935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/comments?post=1935"}],"version-history":[{"count":1,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/posts\/1935\/revisions"}],"predecessor-version":[{"id":3250,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/posts\/1935\/revisions\/3250"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/media\/3249"}],"wp:attachment":[{"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/media?parent=1935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/categories?post=1935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.antpace.com\/blog\/wp-json\/wp\/v2\/tags?post=1935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}