Discover the way to adjust the size of an image to perfectly fit the viewport

Unfortunately, I am unable to provide a perfect explanation for the title's meaning. If you'd like to test the code, please visit

I aim to ensure that the crack and box fit properly regardless of screen size.

While it fits on my monitor, the crack shifts when the screen size is adjusted.

.parent-container{
  margin: auto;
  margin-top: 2vh;
  width: 67vw;
  height: 85.81vh;
  border-top: 2px black solid;
  border-left: 2px black solid;
  border-right: 2px black solid;
}
.container{
  display: flex;
}
.item:nth-child(1){
  flex: 1;
  height: 28vh;
  border-right: 2px black solid;
  border-bottom: 2px black solid;
  font-family: 'Indie Flower', cursive;

}
.item:nth-child(2){
  flex: 2.6;
  height: 28vh;
  border-bottom: 2px black solid;
  font-family: 'Indie Flower', cursive;

}
.item:nth-child(3){
  flex: 1;
  height: 28vh;
  border-left: 2px black solid;
  border-bottom: 2px black solid;
  font-family: 'Indie Flower', cursive;

}

img{
  width: 100%;
  margin-top: -50%;
}
<div class = "parent-container">
  <div class = "container">
    <div class = "item"></div>
    <div class = "item"></div>
    <div class = "item"></div>
  </div>
  <img src="http://dainielhhong.com/page1.html">
</div>

The issue may be due to the large SVG size, but I am uncertain about the exact problem.

Answer №2

Give this CSS solution a shot

img{
  width: 100%;
  margin-top: -50%;
  position: Fixed;
}

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

Switch the hue when altered

My document contains various input elements such as text, radio buttons, and checkboxes. I want each of these elements to change color when a change is made. This is the method I am currently using: $("document").on('click', 'change', ...

Jquery alters the border of a textbox with a single modification

I attempted to implement a validation using regular jQuery and managed to accomplish half of it successfully. When I try to submit an empty field, the textbox border turns red, but if I fill in the value and click the button again, the border doesn't ...

Position the text at the upper center of the div and the button at the bottom

I've got a div container structured like so: <div class="text-offer_dos"> <div class="centrar"> <h3>Lorem ipsum dolor!</h3> <h5></h5> <p class="text"><b>Lorem ipsum dolor ...

An image that is in motion at an inappropriate time

My website has run into an issue. Within the navigation bar, there are two unordered lists containing list items and nested ul tags with images in some of the list items. When applying animations, the image moves along with the tabs. Here are visual exampl ...

What is the best way to make curved lines in CSS without relying on an image?

Seeking to design a website featuring numerous curved lines and borders, as shown in the linked images. Utilizing Vue to ensure consistent appearance across both desktop and mobile platforms without relying on image files unless necessary. Visualization ...

What is the best way to ensure a consistent time interval between invoking two functions in JavaScript?

Is there a way to create a code that will call one function, let's say toStart(), and then immediately call another function, toStop(), exactly two seconds after the first function is initiated? I want this process to continue until a specific button, ...

Locate the table cell that contains certain text, then identify its surrounding elements such as parent elements and

Currently, I am working on a task that involves finding a specific <td> element in a table using Python Selenium. I have successfully located the element based on certain text content it contains. However, upon calling the parent method on the select ...

I'm having trouble aligning two divs side by side

Does anyone have any suggestions on how to align <head> and <head> horizontally? I've attempted using the CSS code below, but it doesn't seem to be working: .header_nav { float:left; clear:both; } You can view the actual pa ...

Assigning a specific tag when utilizing ng-options in Angular

I'm struggling with setting the default value in a dropdown list using ng-option. Can someone take a look at my code and provide some guidance on how to resolve this issue? <div class="form-group"> <label c ...

Changing a p element to a div and adding a class in Bootstrap 4.5

To maintain consistency, I prefer using <div class='something'>BIO</div> over <p>BIO</p>. In Bootstrap 4.5, is there a similar class that achieves the same result? I'm not very skilled in CSS, so please forgive me i ...

The media print is not displaying correctly when attempting to print with JavaScript

I am attempting to print a div using the following javascript code: var divToPrint = document.getElementById(curid); var newTab = window.open('', 'Print-Window'); newTab.document.open(); newTab.document.write('<h ...

Troubleshoot: Why Equal Height Columns in Bootstrap 4 are not functioning

My design includes two columns placed side by side, each containing different content. I assumed this was a default feature in Bootstrap 4 or at least in one of its alpha versions. I have attempted the following: .equal { display: -webkit-box; di ...

Conflicting Transformation Properties Causing CSS Issues Within a Single Element

I'm currently working on a user interface where users can drag and drop a box with a red outline to position it on the screen within a black box. See the UI here Alternatively, users can also move the box by adjusting the inputs on the right side. ...

Creating a stylish login form with Bootstrap: How to effortlessly center it on your webpage

My login form is currently positioned to the left. However, I am trying to move it to the center of the page. I attempted some CSS styles without success. Interestingly, when I removed '{% extends "common/base.html" %}' from the code, the form di ...

What methods can I employ to utilize CSS on a table row that contains a specific class in an HTML

Is there a way to make the CSS affect <tr class="header"> with the class of header? CSS table.table-bordered tr:hover{ background-color: #C0C0A9; } table.table-bordered tr { background-color: #C0C0D9; } Any suggestions on what I ...

Implement jQuery Styling using .toggleClass on Freshly-Added DOM Elements

I am currently developing a webpage with a unique "notepad" widget, and I have made some adjustments to the interface: The notepad is essentially an aesthetically modified <ul> where each line on the notepad page is represented by its own <li> ...

There seems to be an issue with the display of Django, Bootstrap, and nav-tabs

In my Django template generation project, I am working on dynamically populating Bootstrap nav-tabs based on entries in the items parameters. For example, if item1 belongs to room1, then room1 should be displayed as a tab and item1 should be listed there. ...

Creating a JQuery slider with customizable step sizes

Can the JQuery Slider (range slider / dual slider) be customized to handle non-linear values with inconsistent "step" sizes? I envision a horizontal Slider that looks like this: |----|----|----|----|----|--------|--------|-------------------------|------ ...

I am facing an issue where my Popover functions correctly when elements are added using HTML, but not when they are dynamically created

I'm currently working on a method to incorporate multiple popovers that have a similar appearance to the following: The screenshot of my first JsFiddle project (click to view) The initial progress I've made can be seen in my first JsFiddle, acc ...

Hidden Navigation Bar in AngularJS

Is there a way to hide the navBar when the route is "/"? I managed to successfully hide/show the navbar, but the issue arises when the navbar is hidden. The "app-body" div then has 50px of padding top (where the navbar should be). Here is my HT ...