The layout of my HTML webpage displays an overlapping navbar on iPhones, but this issue does not occur on

https://gyazo.com/5879a8f4528bcfb7bc5c8b5cd3f72dd1

The images displayed above are screenshots from different devices - one from my iPhone and the other from my computer on Chrome.

https://gyazo.com/5c4ac3d0cef9b63a92f2649d8e00adba

I have included the relevant CSS and HTML code for reference:

The CSS code can be viewed here:

https://github.com/oskaryil/dev-cafes/blob/master/public/assets/css/main.css#L40-L233

The HTML code is as follows:

<section class="header">
  <div class="nav">
    <div class="nav-left">
      <a href="#" class="nav-title">Dev Cafés</a>
      <a class="nav-location" href="#">
        <i class="fa fa-map-marker" aria-hidden="true"></i>
        Stockholm
      </a>
    </div>
    <div class="nav-right">
      <a class="nav-add">
        <i class="fa fa-plus" aria-hidden="true"></i>
        Add
      </a>
    </div>
  </div>

  </section>
<!-- focus from here -->
<section class="main">

    <div class="cards">
      <ul class="cards-list">
        {{#each venues}}
        <li class="cards-list-item">
          <a href="#" class="cards-link">
            <div class="cards-header-info">


              <div class="cards-header">
                {{#if image}}
                  <img class="blur" src="{{image}}" />
                {{else}}
                  <div class="cards-header-bg">
                  </div>
                {{/if}}
                <p class="cards-header-p">
                  {{name}}, {{adress}}
                </p>
              </div>
 <!-- to here -->
              <div class="cards-info">
                <p>
                  {{description}}
                </p>
                {{#if options.wifi}}
                  <i class="fa fa-wifi availability-icon" data-option="on" aria-hidden="true"></i>
                {{else}}
                  <i class="fa fa-wifi availability-icon" data-option="off" aria-hidden="true"></i>
                {{/if}}
                {{#if options.toilet}}
                  <svg version="1.1" class="toilet-icon availability-icon" y="0" x="0" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" xmlns:xlink="http://www.w3.org/1999/xlink" data-option="on">
                    <g>
                      <g>
                        ...
                        [SVG path continues]
                        ...
                        
                      </g>
                    </g>
                    <g>
                      <g>
                        ...
                        [SVG circle element]
                        ...
                          
                      </g>
                    </g>
                    ...
                     [Additional SVG elements]
                    ...
                    </svg>
                {{else}}
                  <svg version="1.1" class="toilet-icon availability-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 512 512" xml:space="preserve" data-option="off">
                    <g>
                      <g>
                        ... 
                        [Similar SVG path continuation]
                         ...
                      </g>
                    </g>
                   
                       
                    </svg>
                {{/if}}
              </div>
              </div>
          </a>
        </li>
        {{/each}}
      </ul>
  </div>
</section>

JSON object with data that gets sent to handlebars:

 module.exports = [
  {
        name: 'Starbucks Stureplan',
        adress: 'Kungsgatan 2',
        description: 'Very nice place with good drinks and good wifi with nice service.',
        options: {
          wifi: true,
          toilet: true
        },
//this is the image
        image: "https://s-media-cache-ak0.pinimg.com/originals/8f/5f/d0/8f5fd07d1034e0d4941c4ad9d58ec055.jpg"
      },
      {
        name: 'Starbucks Fenix',
        adress: 'Kungsgatan 2',
        description: 'Very nice place with good drinks and good wifi with nice service.',
        options: {
          wifi: true,
          toilet: true
        }
      }
    ]

Please note that this project follows a mobile-first approach:

If any display issues arise due to the placement of the images, you may adjust the margin-top property in the "main" section. However, this may cause some positioning discrepancies on certain devices.

If removing the picture entirely resolves the problem, it might be a viable solution. Keep in mind that using images within handlebars templates requires careful handling to ensure proper display across various devices.

If you encounter difficulties understanding the source of this issue, further debugging or testing may be necessary to pinpoint the root cause.

Answer №1

In the realm of browsers, the website functions smoothly on Chrome but encounters issues on Safari. To tackle this problem, you can identify the specific navigator.userAgent and make adjustments to the element and CSS accordingly.

if (navigator.userAgent.indexOf("Safari") != -1 &&
navigator.userAgent.indexOf("Chrome") == -1) {
$("h1").addClass("safari");
}

I have created a jsFiddle for your convenience

https://jsfiddle.net/01obbpwv/1/

Edit: I overlooked adding jQuery to the fiddle.

Answer №2

I managed to find a solution without the use of JavaScript. All I had to do was enclose the img tag within another div like so:

<div class="child-img">


              {{#if image}}
                <img class="blur" src="{{image}}" />
              {{else}}
                <div class="cards-header-bg">
                </div>
              {{/if}}
</div>

This resolved the issue, and in this scenario, you need to add display: inherit; in the CSS!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Aligning images in columns

I need help aligning a set of images using CSS. Currently, they are stacked top to bottom and I want them to be placed left to right instead. In simpler terms: 1|2|3|4 5|6|7|8 vs 1|3|5|7 2|4|6|8 #photos { line-height: 0; -webkit-column-count: ...

Submitting a form in React/Javascript: A step-by-step guide

I have a website on Wordpress where I am using the Wp-Polls plugin to vote. How can I submit a post request by accessing a form URL in a React project? Specifically, how can I vote for the "Bad" option with a value of 2? The HTML structure of the WordPre ...

Can you explain the distinction between "typeof str" and "typeof(str)" when working with JavaScript?

Can you identify the distinction between these two lines of code? if (typeof errorMessage !== undefined) {} and if (typeof (errorMessage) !== undefined) {} ...

When a user clicks on a link on my website, the value in a textbox on an external website will

I'm the proud owner of a website! Within my own site, I've included a link that directs users to an external website. My question is: How can I set a value in a textbox on that external website when a user clicks the link on my own page? ...

Inserting an image into a <div> means adding a reduced-size image numerous times to fill the Div

I have encountered an issue while using the code provided in the CodePen link below to paste an image into a Div. The problem is that when I paste a small image, it shows up multiple times within the Div if clicked on after pasting. My goal is to display t ...

Using the <select> element for converting selection from C# to JavaScript

I have a ViewBag.List where I store information about competitions and their respective teams. For example, the list includes the Premier League with teams like Arsenal and Chelsea, as well as the Bundesliga with teams like Bayern Munchen and Wolfsburg. I ...

Database-driven cron scheduling

How can I set up a cron job to send an email notification using node-mailer about 1 or 2 weeks before the expiration date of a product in my database that includes an expired_date field? ...

``Where can I find information on setting a timeout for a node.js application

Is it feasible to implement a timeout for running node.js? I am faced with the issue of connecting to external services that occasionally do not respond, causing my script to hang and the node.js process to freeze. I am seeking a solution to enforce the t ...

Empty Button error still occurring on button featuring an icon and labeled with aria-label

Looking for a solution: <button type="button" class="btn btn-default dropdown-toggle" aria-expanded="false" aria-label="Sort"> <i class="fa fa-arrows"></i> </button> Despite having an aria-label, this button is still flagged ...

useEffect was passed an additional argument in this current render cycle

Unable to Resolve Warning Message: A warning message is popping up stating: useEffect received a final argument during this render, but not during the previous render. Even though the final argument is optional, its type cannot change between renders. h ...

Ensure that the control button is pressed during the JavaScript onclick event function

I am looking to create a JavaScript function that checks if the CTRL button is pressed. Here is my PHP code: <tr class="clickable" onclick="gotolink('<?= base_url() . invoices/createinvoice/' . $customer->Id; ?>')"> And here ...

Tips for maintaining tab state using Angular Material

In my Angular 8 application with Angular Material, I have implemented four tabs where each tab allows editing. However, when going back from the edit mode to the tabs, I want the last selected tab to remain selected. My approach so far is as follows: exp ...

Utilizing babel-plugin-root-import in conjunction with babel 7

Recently, I decided to dive into setting up Babel 7 for the first time. It's been a bit of a learning curve as I navigate through unfamiliar territory. While I was able to successfully install and utilize @babel/plugin-proposal-optional-chaining, I&ap ...

Utilizing Angular's mixed binding feature with curly braces in queryParams

Can anyone help me with binding my component's field to the [queryParams] attribute? I tried using this code: <a routerLink="/{{getMyLink()}}" [queryParams]="{ navSource: {{navSource}} }" /> The issue I'm facing is that the outer braces a ...

Preventing JSON data from being altered in AngularJS by creating a duplicate copy

It seems like there might be an issue with my implementation of AngularJS. I am trying to create a copy of a JSON object on page load, generate a form using the original data, and then compare the two JSON objects when the submit button is pressed to deter ...

The problem of undefined icons in Material UI's Stepper StepLabel

Having some trouble incorporating a custom Step Label Icon within the nodes of the Stepper Component provided by Material UI. I want to add an icon to each circle, similar to what is shown in this Material UI demo: https://i.sstatic.net/WLOcS.png However, ...

Error: Unable to access the 'comments' property of a null value

Encountering an issue when trying to add comments to a post, resulting in the error message: TypeError: Cannot read property 'comments' of null Post routes: router.post("/", async (req, res) => { console.log(req.params); Post.findById(r ...

How to Use Jquery to Deactivate a Div with a Background Color

Currently, I have a div that contains several child divs. My goal is to disable the parent div and all of its children, showing them in gray color. I initially tried using the CSS property opacity, but unfortunately, the background color didn't change ...

Sending data back to a previous screen in React Native

Currently, I am facing an issue with passing parameters between two screens: HomeScreen and SavedRoutesScreen. function HomeScreen(props: { //some props route:any, navigation:any, }) { React.useEffect(() => { if (props.route.params?.defin ...

I am sometimes experiencing issues with activating ajax code using Bootstrap 3 modal

I'm stumped trying to find a solution for this issue. Currently, I am utilizing the bootstrap modal to retrieve ajax content from a specified URL. To prevent content overlap, I am using $.removeData() when reloading the content. The problem arises w ...