Adjusting the size of an image in CSS to perfectly fit the browser dimensions

I'm having trouble getting the images to resize properly to fit the browser window just like the background image. I've tried using

max-width:100%;
height:auto;
max-height:100%;

The images don't seem to resize correctly when I adjust the size of the browser window. They end up moving around instead of staying in place. Any suggestions on what I might be missing?

body{
  background: url(http://www.planwallpaper.com/static/images/518169-backgrounds.jpg)no-repeat center center fixed;
 background-size: 100%;

}
.boat2{
  width: 400px;
  position:absolute; bottom: 160px; left: 800px;z-index: 1;

}
.cabbage{
  width: 150px;
position:absolute; bottom: 290px; right: 290px;z-index: 1;
}
.sheep{
  width: 150px;
  position:absolute; bottom: 300px; right: 180px;z-index: 1;
}
.wolf{
  width: 300px;
  position:absolute; bottom: 270px; right: -80px;z-index: 1;
}
img {
  max-width:100%;
 height:auto;
 max-height:100%;
}
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="style.css">

    <title>IQ River Crossing</title>

</head>
<body>
<div class="image">
<img class="boat2"src="http://www.planwallpaper.com/static/images/christmas-background.jpg" alt="">
<img class="cabbage" src="http://www.planwallpaper.com/static/images/christmas-background.jpg" alt="">
<img class="sheep" src="http://www.planwallpaper.com/static/images/christmas-background.jpg" alt="">
<img class="wolf" src="http://www.planwallpaper.com/static/images/christmas-background.jpg" alt="">
</div>

</body>
</html>

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

Navigation buttons that move the user either up or down the page

I am a beginner in programming and I wanted to create two buttons for my webpage. One button should appear when the page is scrolled more than 300px and take the user to the top, while the other button should be displayed immediately and scroll the user to ...

Remove unnecessary margins from grid layout

I'm looking to create a grid display using divs with inline-block display and margin-right. However, I'm facing an issue where the last item on each row also has a redundant margin-right. Here's a snippet of my CSS: .item{ height:20px; ...

Toggle Visibility of Elements with Javascript and Html

I've been working on implementing a "Show All / Hide All" feature. Currently, clicking on the text opens the image and text individually. However, I am looking to add a functionality for expanding all divs at once. To see how it currently functions, ...

Is it achievable through CSS alone to eliminate the bullet point in a UL list when it consists of just a single item?

Is it feasible to achieve a solution using CSS alone that remains functional even on IE8, ensuring the following criteria: If a <ul> list contains 2 or more items, then maintain the bullets in front of each item as per usual. When there is only one ...

How can I create a responsive navigation bar in Bootstrap that displays a menu button and collapses the list items when the browser is resized?

I am looking to create a navigation bar that transforms into a menu button and collapses when the browser window is minimized. I would like it to function similarly to the one found at . While I have searched for tutorials, most only cover how to create ...

I am looking to create a rounded circular progress bar with smooth edges

I'm looking to create a circular progress bar with rounded edges on the highlighted segment, similar to this example: https://i.sstatic.net/kNKyzm.png While I've managed to create a basic version, I'm struggling to achieve the rounded ends ...

Exclusive CSS banner slider glitch - Hyperlinked images unresponsive

.zd-slider { position:relative; overflow:hidden; margin-top: 0px; } .zd-slider img[id*="img"] {width:100%; position:absolute; left:0; top:0; opacity:0; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";} /* Set the width/height of the slide ...

When using Angular, automatically shift focus to the next input field by pressing the

I am faced with a challenge involving multiple editable inputs on my screen. Alongside these editable inputs, there are buttons and disabled inputs present. The current behavior is such that when I press Tab, the focus shifts to the HTML elements between ...

What is the best way to adjust the size of a background image on Safari

Using Chrome When using Chrome, the functionality is just like what's depicted in the image above. However, when using Safari The issue arises, as it does not work as expected in Safari. See below for the CSS code: background-image: url(r ...

What is the best way to dynamically display a user's username in the header when they are logged in using PHP?

I've been searching online for a solution, but I can't seem to find one. I've tried various approaches, but nothing seems to work. My header always displays "Login" instead of showing "Welcome User" and a logout button. The code I have looks ...

Manage the element that should receive focus() after tab is pressed from an input field

On my webpage, there is a variety of elements such as inputs and anchors. I need to specify which input field the browser should move focus to when I press the tab key while on an input. Currently, pressing tab from one specific input takes me to a menu i ...

Display the delete message URL according to the user's name

I have a wall message system using PHP and jQuery where messages from all users are displayed. Now, I want to add delete functionality to each message, but the delete link should only be visible to the user who posted the message. .childs { opaci ...

Experimenting with Angular using a template that includes a mat-toolbar

Currently, I am in the process of writing tests for my Angular application. Here is a snippet of the template used in my AppComponent: <mat-toolbar color="primary"> <span>CRUD Exercise</span> <span class="example-spa ...

Retrieving the chosen option from a dropdown menu using AngularJS

<tr (click)="onRowClick(myDropDownList.value)"> <td> <select #myDropDownList (click)="$event.stopPropagation()" (change)="onChange($event.target.value)"> <option *ngFor="let n of numbers" [value]="n">{{n}}</option> </se ...

Having several contact forms embedded within a single webpage

I am currently in the process of developing a prototype website and my objective is to have multiple forms on a single page. My goal is to have a form for each service, where users can click on the service and fill out a form to request a quote. The first ...

Is there a way to smoothly incorporate a new animation into a page, while ensuring that existing elements adjust to make room for it?

I am looking to smoothly fade and move a hidden element (display:none) within the page, shifting other elements to animate into their new positions as necessary. When I reveal the hidden element by changing it to "display:initial," it should seamlessly a ...

Substitute content in HTML using jQuery along with JavaScript functionalities

[UPDATE: I've condensed the relevant excerpt from my code. I acknowledge this may have caused some confusion. My apologies for any misunderstanding. Here's a snippet that reproduces the issue: After the snippet loads, click on the button. < ...

The CSS background cannot be blurred

After constructing a basic HTML page, I decided to incorporate the following CSS code: html { background: url("photourl") no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover ...

Is there a way to display a unique image depending on the user's chosen color scheme?

I am attempting to utilize a next/image instead of a traditional img tag in the code snippet below. Using a regular <img> tag, the following code achieves exactly what I desire: <div> <picture> <source srcSet="https://vi ...

How to eliminate a hyperlink from an HTML element with the help of JQuery

Recently, I was assigned to revamp a website for the company I work for. However, upon closer inspection, I realized that the website is quite messy and relies heavily on templates, resulting in certain elements being auto-generated as active links. The i ...