What are the proper steps to ensure images are displayed correctly on mobile devices?

https://i.sstatic.net/M68Ob.jpg

https://i.sstatic.net/fPKXr.jpg

Our background image is 1920x1080p and looks great on desktop browsers, but it's not displaying properly on mobile devices in either portrait or landscape mode. Is there a way to resolve this issue without needing multiple images? Can we automatically resize the image using CSS?

#tf-home{
    background: url(../images/OdysseyTitleImage.jpg);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: #cfcfcf;
}

#tf-home .overlay{
    background: -moz-linear-gradient(top,  rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.73) 17%, rgba(0,0,0,0.66) 35%, rgba(0,0,0,0.55) 62%, rgba(0,0,0,0.4) 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.8)), color-stop(17%,rgba(0,0,0,0.73)), color-stop(35%,rgba(0,0,0,0.66)), color-stop(62%,rgba(0,0,0,0.55)), color-stop(100%,rgba(0,0,0,0.4))); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top,  rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.73) 17%,rgba(0,0,0,0.66) 35%,rgba(0,0,0,0.55) 62%,rgba(0,0,0,0.4) 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top,  rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.73) 17%,rgba(0,0,0,0.66) 35%,rgba(0,0,0,0.55) 62%,rgba(0,0,0,0.4) 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top,  rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.73) 17%,rgba(0,0,0,0.66) 35%,rgba(0,0,0,0.55) 62%,rgba(0,0,0,0.4) 100%); /* IE10+ */
    background: linear-gradient(to bottom,  rgba(0,0,0,0.8) 0%,rgba(0,0,0,0.73) 17%,rgba(0,0,0,0.66) 35%,rgba(0,0,0,0.55) 62%,rgba(0,0,0,0.4) 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cc000000', endColorstr='#66000000',GradientType=0 ); /* IE6-9 */
    height: 1080px;
    background-attachment: fixed;
}
.home-lead{
    color: #fff;
    padding: 10px 15px;
    background-color: rgba(51, 51, 51, 0.9);
    font-size: 21px;
}
.content{
    position: relative;
    padding: 30% 0 0;
}

Here is the HTML content:

<div id="tf-home" class="text-center">
    <div class="overlay">
        <div class="content">
            <div><a href="https://www.youtube.com/watch?v=HRlP0t41wCw" class="btn tf-btn btn-default popup-video">Watch the trailer</a></div>
            <a href="#tf-game" class="fa fa-angle-down page-scroll"></a>
        </div>
    </div>
</div>

Answer №1

The height: 1080px; in #tf-home .overlay is likely the cause of this issue. While it may look fine on desktop due to sufficient space, the same height is applied to mobile which results in the graphic appearing much larger than intended for mobile viewports.

Consider adjusting the height using a media query specifically for mobile devices. For example:

@media (max-width: 600px) {
    #tf-home{
        background-attachment: scroll;
    }
    #tf-home .overlay {
        height: 320px;
    }
}

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

What are some creative ways to design drop-down menus within an email?

The snippet of code I am currently using lacks the ability to format text, and it does not allow content below dropdown items to shift down properly in an email. <select> <option value="first">First-time users of the Vanguard Events app:&l ...

Material User Interface, MUI, Modal, Back to Top Scroll按钮

After spending some time experimenting with scrollTop and the Dialog component (a fullscreen fixed modal) from Material-ui, I found that I couldn't quite get scrollTop to function properly. Whenever I clicked the "go down" button, it would either retu ...

Comparing the use of jQuery click event with the button to trigger a function that calculates the

Currently, I am grappling with a JQuery function that checks if any checkboxes are ticked within my form. My version of JQuery is v1.10.2. The code functions as expected when triggered by a button, but when I attempt to trigger it with a checkbox within t ...

Error in Compiling HTML Elements Collection<<Element>

Currently, I am developing an eCommerce application that features a popup window for users when they click on "Add to Cart." This popup allows users to select product variations and quantities before adding the item to their cart. The popup consists of a s ...

Modify CSS using Javascript by targeting the class of ".modalDialog > div {}"

I am currently working on a project that involves creating a Modal Layer using CSS. I have successfully implemented the modal layer, but now I need to figure out how to change the width from the default 400px to something else when I open it with Javascrip ...

How to Blend Pseudo-classes in CSS?

If I want the selected text in a link to turn red when hovered over, can I achieve that using the following CSS code? .abc:hover::selection {color: red;} Also, if I have the following link: <a href="123" class="abc">4567890</a ...

How to locate a div element using CSS selector in Selenium WebDriver with Ruby

My experience with CSS selectors in selenium webdriver has been positive, but I am facing difficulty in locating the element within the following div. <div class="class1 class2" dd:btnfloatingstyle="top-right" dd:entitytexttype="resultval" id="_78891a3 ...

Add a date to my database using an HTML form

I am having trouble inserting a date into my database using PHP. Everything else inserts correctly, but the date reverts to the default 0000-00-00 as if nothing was entered. I have set the data type for the date field. Here is the code snippet: <?php ...

Extracting information from an HTML table with Jsoup

Currently, I am attempting to utilize jsoup in order to parse an HTML table. As a newcomer to jsoup, I have taken the time to review some tutorials on how it operates. My objective is to retrieve values from each column within this specific website's ...

Tips for customizing the scrollbar design in iOS Safari

Task at hand requires me to customize the scrollbar style on my HTML page. Below is the CSS code I am using: .txt_Content::-webkit-scrollbar { width:5px; border-radius:4px; } .txt_Content::-webkit-scrollbar-button { display: none; } .txt_Co ...

PHP - WebCalendar - Show or Hide Field According to Selected Item in Dropdown List

Working with the WebCalendar app found at to make some personalized adjustments to how extra fields function. I've set up two additional fields: one is a dropdown list of counties, and the other is a text field. Within the dropdown list, there is an ...

Create code with a form button and showcase the produced code on the webpage

I have created two files: code_generator.html, which takes input in the form of an image URL and landing URL. When I click on the submit button, it calls code_created.php. <html> <head> </head> <body> <form a ...

What is the best way to modify a variable in a nested element using ng-click in the parent element?

Review this code snippet: <section class="page-section about-us" scroll-bookmark="about-us" ng-click="activeSection=true" ng-init="activeSection=false"> <div class="page-content sub-content active-section">{{activeSection}} < ...

Activate the radio button upon page load in angularjs

<div class="form-group" style="margin-top: 20px;" ng-repeat="row in skuDetails"> <label class="checkbox-inline"> <input type="radio" name="amount_{{$index}}" value="amount" ng-model="row.amount" ng-checked="row.reductionAmount != &apos ...

Switching the cursor to an image when hovering over an element is causing inconsistency in hover events triggering

Currently, I am attempting to implement an effect that changes the cursor to an image when hovering over a text element and reverts back to the normal cursor upon leaving the text element. However, this functionality is not working as expected when using R ...

The image spills out of its confines

Looking to create a dialogue box that fills the entire width and height of the screen? Want to divide its content into two sections - an image and a footer area with 2 rows of height? Struggling to contain the image within its designated space without over ...

Is there a way to align six columns on the left side and have a dynamic column on the right that fills the width of the browser window?

Is there a way to make a fluid container in Bootstrap 5 that contains a normal container on the left with 6 columns of content, while allowing the right side of the container to expand to the end of the browser window? When using a normal fluid container, ...

Converting numerical values into currency format using Angular

Can anyone provide guidance on how to format a number received from the API as currency in Angular 15? This is what my HTML currently looks like: <thead class="fixed-top cabecalhoTabela"> <mat-card-header> & ...

Non-clickable image

My social media page icons are not hyperlinked, and I can't figure out why. I've surrounded them with the href attribute, but for some reason, it's not working. Can anyone provide assistance? Here is the HTML code: <!DOCTYPE html> ...

Tips for transferring custom data on a form without relying on input fields are an effective way

Is there a way to submit a form with both name and quantity without having an input field for the second variable? I want the quantity get variable to be passed when the form is submitted, but I also need to pass the name quantity that is already displayed ...