When resizing my web page, the content overlaps and the images become distorted

Although the page appears fine in normal view mode, an issue arises when the page size is reduced - the image within the body tag vanishes. Multiple attempts have been made to rectify this problem by altering the code, but unfortunately, none have proven successful.

    <!DOCTYPE html5>
    <html>
    <head>
        <meta name="viewport" content="width=device-width,initial-scale=1.0 ">
        <link type="text/css" rel="stylesheet" href="style.css" />
        <title> home
        </title>
        <style>
                .wrapper {
                         background-color: #66aaee;
                         position:relative;
                         width: 100%; 
                         min-width: 100%; 
                         max-width: 100%;
                         min-height: 100%;
                         max-height: 500%;}
  <!--wrapper is the main div that contains all the content of the page -->  

                .header{
                    background-color: #66bbff;
                    width: 100%;               
                    height: 21.5%;              
                    margin-top: -8%;
                    position: fixed;
                    z-index: 2;}            
    <!-- navigation is a div inside the header and it contains all the menu  -->
                .navigation{                

                            margin-left: 15%;
                            width: 500px;           
                            float: none;}

                 .body {                
                        background-color: black;
                        height: 95%;
                        margin-left: 10%;
                        margin-top:8%;                  
                        width: 80%;
                        }
                 .body img {margin-left: 10%;
                            margin-top: 7%;                    
                            width: inherit;                     
                            float: none;
                            overflow: hidden;}  

                 .body_down {
                             height: 90%;
                             background-color:#44aacc;
                             font-size: 20px;
                             margin-top: 1%;
                            position: relative;
                            z-index: 1;}
<!--body_down is another div that contains some of the body content -->

                 .footer{                   
                        background-color:#ffffff;
                        font-size: 20px;
                        margin-top: 100%;}               

        </style>
    </head>

        <body>
                <div class="wrapper">
                        <div class="header">                        

                                    <div class="navigation">
                                    <img src="image/header.png" width="800px">
                                        <nav>

                                                <ul>
                                                        <li>    <a href="#" style="text-decoration:none" target_="blank"> Home </a> </li>   
                                                        <li>    <a href="#" style="text-decoration:none">About </a>  </li>
                                                        <li>    <a href="#" style ="text-decoration:none"> About Research Buddies </a>  </li>
                                                        <li>    <a href="#" style="text-decoration:none">Products and services </a>  
                                                                <ul>
                                                                        <li> GRAPHIC DESIGN </li>
                                                                        <li> CITATIONS </li>
                                                                        <li> PRINTING </a> </li>
                                                                        <li> PUBLISHING </li>
                                                                        <li> PHOTO EDITING </li>

                                                                </ul>
                                                        </li>
                                                        <li>    <a href="#" style="text-decoration:none"> Promotions </a>  </li>
                                                        <li>    <a href="#" style ="text-decoration:none"> FAQs </a> </li> 
                                                        <li>    <a href="#" style="text-decoration:none"> Contact us </a> </li>
                                                </ul>
                                        </nav>
                                    </div>
                        </div>

                                                                <div class="body"> 

                                                                                    <img src="image/ww.jpg"/>

                                                                </div>
                                                                                <div class="body_down">
                                                                                        body content continues here
                                                                                </div>


                                                    <div class="footer"> 
                                                        the footer is here
                                                    </div>
                </div>
        </body>

    </html>

During normal viewing, the page presents as expected. However, issues arise as the page's size decreases, causing the image within the body tag to disappear. Despite numerous attempts to fix this problem through code editing, a solution remains elusive.

Answer №1

It is recommended to eliminate the width property from the img element.

Instead, apply the following custom CSS:

.img-fluid {
  max-width: 100%;
  height: auto;
}

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

Is there a way to deactivate a clickable div immediately after it has been clicked on?

I have been searching for a solution to this particular question on different platforms, including Stack Overflow. However, I am looking for an answer using pure JavaScript only, so please avoid jQuery solutions. In order to provide context, I have includ ...

Error encountered while trying to upload a file using PHP on a hosting platform

Hey everyone, I'm feeling really frustrated right now because I'm facing a file upload error in my PHP code. The issue is that the file is not getting uploaded to my folder and no error messages are being displayed. I've been working on cr ...

How to center an HTML header

Currently working on a one-page scrollable website, aiming to have the first page consist of a navbar, image, and header. The challenge I'm facing is centered around aligning the header vertically. Although I managed to center it horizontally, the ver ...

The background image is not appearing on the div as expected

I've been attempting to create a div and set a background image for it using jQuery, but I seem to be facing issues. When I try setting the background color to white, it works fine. Here's the code snippet: function appendToDom(poster) { ...

Update the value of an ASP textbox using JQuery, and ensure that the .Text property accurately reflects the new value

After searching extensively, I still haven't been able to find a solution to my problem. I am facing an issue with updating a readonly Textbox in ASP.NET using JQuery after selecting radio buttons. The value displays correctly and everything seems to ...

Ensure that the context is used to effectively clear any existing data from the previous bar chart

I recently came across a cool codepen demo on this link. Upon clicking the first button followed by the second, the data transitions smoothly. However, there seems to be an issue where when hovering randomly over the bar charts at this source, the value ...

Include dimensions in the images using the width and height attributes, either in the HTML or CSS code

I've recently been working on my wordpress site and have made a change to how I handle image sizes. I've been removing the width and height attributes when adding images, as they are automatically added. Instead, I've been using the followin ...

Is there a way to have a content's columns adjust to the size of an image?

I'm currently struggling with a layout issue. I have an image on the left and want the content columns on the right (title, lorem...) to adjust their height to match the image. How can I achieve this? I'm using Bootstrap v5.1.1 Current image: ...

The <span> element stubbornly resists aligning inline within a flexbox container

Within a flexbox a element, I have a div that contains a span with the class .time-pretext: <a class="option-container option-edit-time" href="#"> <div class="option-icon"><canvas id="time-canvas" width="128" height="128"></canvas&g ...

Using importXML with Internet Explorer 11

My project website includes a roster page that retrieves XML data. Previously, this functionality worked across all browsers but now it only works in Chrome. In IE11, it seems that the importXML function is not functioning correctly as the roster data is m ...

Issue with click function not activating in Chrome when using Angular 6

I am facing an issue where the (click) function is not triggering in my select tag when I use Google Chrome, but it works fine in Mozilla. Below is my code: <div class="col-xl-4 col-lg-9"> <select formControlName="deptId" class="form-control ...

Accessing geolocation on a mobile web browser: A step-by-step guide

I have implemented HTML5 geolocation functionality using code I found in the documentation: getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(this.showPosition, this.showError); } else { alert("Geoloc ...

The functionality of Angular.js route seems to be malfunctioning

Hello friends, I am fairly new to working with AngularJS and have been experimenting with angular Route. However, I encountered an issue where clicking on #/home resulted in a strange URL appearing here. Oddly enough, the default otherwise condition seems ...

Creating a text box and a clickable button in HTML

How can I make the search button connected to the input in Bootstrap 3? Example: |INPUT|SEARCH| <== they are together <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/cs ...

Tips for integrating Css/JQuery files into an external page on an Android WebView

Uncertain if my desired idea is feasible or not, but why not try now. The structure of my MVC4 Master page is as follows: <head runat="server"> <meta charset="utf-8" /> <title>RYTE HCMS</title> <meta name="viewport" ...

The menu positioned beneath the logo is malfunctioning

Upon downloading a template from the internet, I created a menu at the top with the logo positioned below it. However, when scrolling down, the menu items were supposed to turn black with a white background, resembling this: https://i.sstatic.net/1HTLZ.jp ...

The background image causes the scrollbar to vanish

As a beginner, I am in the process of creating a web page that features a consistent background image. However, I have encountered an issue where the scroll bar does not appear on a specific page called "family details" due to the background image. I atte ...

I am interested in creating a design where two DIVs are layered on top of each other with one having transparency, allowing visibility through to the background DIV. This can be achieved using a combination of

Looking to enhance the visual appeal of my website, I decided to incorporate a background image within a div. To add more depth and creativity, I am now striving to overlay a semi-transparent black box on top of the image. This overlay will not only allo ...

How can we stop the constant fluctuation of the last number on a number input field with a maxLength restriction

In my ReactJS code, I have an input field that looks like this: <input type="number" onKeyPress={handleKeyPress} maxLength={3} min="0" max="999" step=".1" onPaste={handlePaste} /> Below are the functions associated w ...

Learn the process of generating sequential heading numbers for topic headings in each HTML document using DTA or XHTML

I attempted to include hierarchical numbers for topic headings in dita2xhtml_eclipsehelp.xsl. (DITA OT HTML output) However, I am facing difficulty in producing numbers similar to the following in each html file: 1 heading text 1.1 heading text 1.1.1 Head ...