Adjust the height of the background image to 100% by rotating it

I'm struggling to create responsive images with a rotation angle of 10 degrees. However, the height is increasing too much and the image is not centered or covering the full width.

This is what I have so far: (colors are set as background-image). As you can see, the rotation is causing issues where the top and bottom sides are not fully filled, and my overall height is expanding too much.

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

*Here is the CSS code I'm using:

.rotate > div {
    transform: scale(1) rotate(-10deg) translateX(0px) translateY(0px) skewX(0deg) skewY(0deg);
  }
.rotate > div > div > div {
   transform: scale(1) rotate(10deg) translateX(0px) translateY(0px) skewX(0deg) skewY(0deg);
}
.full {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
  }
  .list {
    position: relative;
    width: 100%;
    height: 100%;
  }
  .item {
    height: 50%;
  }
  .wrapper {
    width: 100%;
    height: 100%;
  }

Any help or suggestions would be greatly appreciated!

Answer №1

Utilize the images within a pseudo element and allow for some overflow to fill in the white space:

body {
 margin:0;
 min-height:500px;
 height:100vh;
 overflow:hidden;
}
.box {
  height:50%;
  box-sizing:border-box;
  position:relative;
}
.box:before {
  content:"";
  position:absolute;
  top:-40%;
  left:-10%;
  right:-10%;
  bottom:-40%;
  transform:rotate(-10deg);
  background:var(--i) center/cover no-repeat;
}
.box.first::before {
  bottom:0;
}
.box.last::before {
  top:0;
}
<div class="box first" style="--i:url(https://picsum.photos/1000/800?image=0)">

</div>
<div class="box last" style="--i:url(https://picsum.photos/1000/800?image=1069)">

</div>

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

Tips for avoiding the lower section of your webpage from being cut off on mobile devices

I am trying to create an overlay on top of an Ionic page that should appear right after the ion-content section. However, I am encountering an issue where the lower part of the overlay, where an arrow starts, is not visible on my Moto X Play device. How c ...

Switch the GChart graph type using a button in Vue

<GChart id="theChart" :type="newChartType" :data="chartData" :options="chartOptions()" :resize-debounce="500" :events="chartEvents" ref="gChart" /> < ...

How can I create a floating thumbnail gallery that displays extra content when hovered over? Is there a way to make the hovered thumbnail overlap its neighboring

I am currently working on a gallery of thumbnail images. Each image is accompanied by a title below it: <div class='gallery'> <div class='thumb'> <div class='thumbimage'></div> <div class ...

Issues with CSS background colors

I am in the process of streamlining my CSS code by consolidating repetitive elements and removing unnecessary lines (I am currently enrolled in a mobile apps course that emphasizes creating web-based hybrid applications using HTML5, CSS, and JavaScript, he ...

Always take the lead with the first image in navigation

Looking to add an image to your website navigation? Want the image to appear at the beginning of the navigation bar, before Link 1? Here's a bit of CSS code for you: <div class="topnav"> <img src="https://cdn.mos.cms.futurecdn ...

suggesting options comparable to addthis or sharethis

Could you please check out ? There is a sharing box in the bottom right corner that resembles ShareThis. However, as far as I know, ShareThis does not have options for embedding or submitting content. Does anyone happen to know which plugin is being used ...

Struggling to resize tables in React Material-UI

Here is my SandBox link for reference: https://codesandbox.io/embed/material-demo-j6pz9?fontsize=14&hidenavigation=1&theme=dark I am attempting to organize content within a card using an inline grid display to have them appear side by side. I unde ...

The Bootstrap CSS styles seem to be malfunctioning following the upgrade from Angular 4 to Angular 5

Developed a Single Page Application with Angular 4 and .NET Core 2, integrated with Bootstrap for styling. However, upon upgrading from Angular 4 to Angular 5, the Bootstrap styling disappeared. It seems that the bootstrap.css file is not being loaded cor ...

Prevent users from downloading images

I'm trying to prevent image downloads by regular users, like so: <div style="background-image: url(img.jpg); background-size: cover; background-repeat: none; "> <img src="wtrmrk.jpg" style=" opacity: 0; " /> </div> If the img.jpg s ...

Fetching data from a DIV element

I am trying to figure out how to assign a value from a div tag (6.897882999999999, 79.92221100000006) to a PHP variable using the div's id. Can anyone help me with this? Thank you. <form id="mainForm" method="post" action=""> &l ...

What is the best way to extract hidden content from a website using Python when it's concealed using JavaScript?

Currently, I am enrolled in a course where we are learning how to scrape websites using Python. The specific website that I am working on is "", which is a charity platform. My main goal is to extract information about the contributors to this particular p ...

The calculator is not simply adding two numbers; instead, it is combining them together to display something like "2+2=22"

<title>Calculator</title> <script type="text/javascript"> function Calculate(){ var myWorker = document.getElementById('myOperation'); var numberOne= document.getElementById('firstNumber').value; ...

Modifying ID styling using JavaScript on Internet Explorer

I need to change the CSS display property from none to block using JavaScript, but only for Internet Explorer. My current code is not working for the ID #backfill-image. <script> function checkForIE() { var userAgent = navigator.userAgent; ...

Stop browsers from automatically filling out fields that are hidden

Our method involves jQuery to conceal irrelevant fields based on previous responses. It's puzzling how the browser (Chrome) has somehow autofilled the user's email address into one of them even though autocomplete is disabled. The field's ID ...

Selecting and Uploading Multiple Files in Internet Explorer (less than version 9)

I have been struggling with selecting and uploading multiple files at once to the server. Here is the code I am currently using: <html> <body> <form action="upload.php" method="post" enctype="multipart/form-data" name="myForm"> <l ...

The image tag is being used to show the exact location, however, there is no

How can I load a previously uploaded image via ID in the controller? The controller passes the correct location to the view, but the view does not display the image. When I inspect the view page, it shows the correct ID and location but does not render the ...

Image staying in place when browser page is resized

Half page browser Full page browser Hello everyone, I could really use some assistance with my program. I'm trying to figure out how to keep my robot in the same position when switching from a half-page browser to a full-screen browser. Currently, w ...

using css to pass arguments

I need help with a code that I have, here's the structure: <div className="site-col-1"> content 1 </div> <div className="site-col-2"> content 2 </div> Here is how the corresponding CSS file looks... .s ...

Challenges arise when trying to maintain a div aligned to the far right of the browser window as the dimensions of the browser change, especially after applying an

I have a main container div that holds two smaller divs side by side. When one of these smaller divs is clicked, it moves to the far left or right side of the browser window depending on which one was clicked. This functionality works perfectly as intended ...

Link inserted in between spaces

Working with Eloqua. Any ideas on what might be causing a space to appear in a link? The space doesn't show up during testing, only in the live version. Here is the code snippet: <p style="line-height:18px;"> <font face="calibri, Arial, H ...