I am currently facing a challenge in styling an image to fit into the navigation bar of a website and serve as the logo. The issue I'm encountering is that the appearance of the image varies across the three main browsers.
Specifically, adjusting the height
property to make the image display correctly in Firefox results in it being too large for Safari, and vice versa. Chrome's behavior adds another layer of complexity, as it seems to completely ignore the existence of the relevant class. Upon inspecting the Page Source Code
and reviewing the CSS in question, the class .logo-img
is missing from the code snippet below.
HTML:
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a href="index.html" class="navbar-brand"><img src="{% static "tshirt-theme/img/logo-kindbook.png" %}" class="logo-img" alt="Shirt Store"></a>
<div class="navbar-buttons">
<button type="button" data-toggle="collapse" data-target=".navbar-collapse" class="navbar-toggle navbar-btn">Menu<i class="fa fa-align-justify"></i></button>
</div>
</div>
Additional content omitted for conciseness
CSS:
.navbar-default {
background-color: #ffffff;
border-bottom-color: transparent;
}
.navbar-default .navbar-brand {
color: #333333;
}
img.logo-img {
height: 300%; !important
}
.logo-img > img {
height: 300%; !important
}
Please excuse the use of !important
as I included it while troubleshooting and attempting to find a workaround.
Firefox:
https://i.sstatic.net/0lu93.png
Safari: https://i.sstatic.net/iPz1y.png
Chrome: The image expands to its full resolution and takes up the entire page.
The underlying question addresses why this occurs (especially Chrome failing to recognize the CSS class) and seeks guidance on achieving cross-browser compatibility?