Customize the X and Y position of the CSS background with specific degrees

Looking for help customizing the background position in a PSD image to adjust the slope at the top, right-left side, and bottom. Here is my PSD: https://i.stack.imgur.com/Jr4h7.png

Below is some of my CSS code:

html{
background:#aea99f;
}
body{
background-image: url("http://i.imgur.com/H3fh4Ht.png");
background-repeat: repeat;
background-position: 48% 20%;
margin: 0 auto;
width: 94%;
}

Any suggestions on how to achieve the desired customization?

Here is a JS example for reference: http://jsfiddle.net/zmkkdj46/

Thank you!

Answer №1

Take a look at this Example: fiddle

HTML:

<div>
 123
</div>

CSS:

div{
 width: 94%;
 height:100%;
 background: #fff;
 -webkit-clip-path: polygon(9% 100%, 94% 100%, 100% 0, 0 0);
 clip-path: polygon(9% 100%, 94% 100%, 100% 0, 0 0);
}

html, body {width:100%; height: 100%; background:#aea99f;}
body{display:flex; justify-content:center; align-items:center; padding:0px; margin:0px;}

Answer №2

Expanding on Jagdish's response, to ensure compatibility with Firefox, you will need to include the following code:

HTML

    <div id="div1">
  123 rtrrrrr rt

</div>
<svg id="svg1">
    <defs>
        <clippath id="my-definition" clipPathUnits="objectBoundingBox">
            <polygon points=".09 1, 0.94 1, 1 0, 0 0"></polygon>
        </clippath>
    </defs>
</svg>

CSS

div{
    width: 94%;
    height:100%;
    background: #fff;
    -webkit-clip-path: polygon(9% 100%, 94% 100%, 100% 0, 0 0);
clip-path: url(#my-definition)
}
svg{
  width: 1%;
    height:100%;
}
html, body {width:100%; height: 100%; background:#aea99f;}
body{display:flex; justify-content:center; align-items:center; padding:0px; margin:0px;}

Updated Fiddle Link :

By including the

clipPathUnits="objectBoundingBox"
attribute, your code should work properly in Firefox.

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

Maximizing Bootstrap card size in Angular4: A step-by-step guide

How can I make Bootstrap cards resizable on top of other elements when clicked on an icon to make it full screen and overlay on other cards? detail.component.html <div class="card card-outline-info" > <div class="card-header bg-info"><h5 ...

Converting a 'div' element into a dropdown menu with CSS and Jquery

I am facing a challenge where I have a collection of buttons enclosed in a div that I want to resemble a dropdown: <div id = "group"> <label> Group: </ label> <div value =" 1hour "> 1h < / div> <div value =" 2hou ...

The issue of column sizing in bootstrap 4 needs to be resolved

I'm having trouble making the form input fill the width of the screen on small devices. It works fine on larger screens but doesn't respond properly on phones like it should. <div class="container-fluid"> <div class="row"> ...

Ensuring the accuracy of checkboxes in a loop through verification

How can I ensure that at least one checkbox is selected before allowing the user to move on to the next page using JavaScript with a form structure like this? echo "<form method=\"POST\" action=\"confirm.php\">"; $query = mysqli_ ...

Experience the advanced NgPrime p-dropdown template with templating, filtering, and a clear icon that collapses when wrapped within a form element

Check out this link for a demo Whenever I enclose the code below in a </form> element, the drop-down menu collapses. <h5>Advanced with Templating, Filtering and Clear Icon</h5> <p-dropdown [options]="countries" [(ngModel)]=& ...

Directing a webpage to a particular moment within that page

Is it possible to automatically redirect users to a new page at a specific time? I would like visitors to be redirected to a new site starting from 12:00AM on December 31st, without allowing them to access the current site after that time. Is there a way ...

I'm overwhelmed by the concept of linear gradients

I've been struggling to recreate the CSS gradient, so here's what I'm aiming for: https://i.sstatic.net/4gIHV.png Here are the details: Gradient colors: Start color: #1696B6 with 50% opacity End color: Black with 100% transparency https:// ...

Folding without extending

My button has a div inside it with content. I've set it up so that when the div is clicked, the collapsed content expands. The hover effect changes color and pointer as expected. But for some reason, clicking on the div doesn't expand the content ...

Is it permissible to have <ul> tags within an H1 element?

I am curious about whether adding a list inside an H1 heading could cause any issues: <h1> <ul> <li><a href="...">some link</a></li> <li><a href="...">another link</a></li> <li>curre ...

Minimizing the menu bar while scrolling down (bootstrap3)

Could anyone help me with creating a navigation-bar effect similar to the one seen on ? I want the bar to shrink and the logo to change after scrolling down my page. My website is built using bootstrap 3. Is there a simple way to achieve this effect with ...

Is it possible to conceal any spans that are in close proximity to the cursor when hovered over?

Currently, I am working on a project that involves multiple spans placed side by side, with each span containing a letter of the text. My aim is to create a functionality where hovering over one of these spans will not only hide that particular span but al ...

Text overlaps when li element is nested inside another element

Seeking assistance in creating a CSS/HTML menu bar that triggers list elements on hover. Facing difficulty arranging the list in two columns. Code Sample:http://jsfiddle.net/Km922/1/ <!DOCTYPE html> <html lang="en"> <head> <meta ...

html input type called array named AmountMap[1] is unable to be configured with <input type="textbox" size="15" name="amountMap[1]" value="0" >

**Having trouble setting the value of an HTML input type named like an array AmountMap[1] <input type="textbox" size="15" name="amountMap[1]" value="0" > When trying to set amountMap[1].value='10', ...

Make sure the page preloader is visible before any other content is loaded

Currently, I am working on a straightforward preloader page that remains visible until the main content of the page is completely loaded. Despite the functionality of the loading page, my main concern lies in the quick display of the main content before th ...

Javascript continues to conceal my web background without my permission

After loading my webpage, I click on a link and the expected javascript runs as planned. However, once it completes and presents the results, the page goes blank to a white screen displaying only the outcomes. My goal is to have these results showcased o ...

The Facebook like button disappears after being used just once

I've encountered an odd issue that hopefully someone can help me understand. WEBSITE: ISSUE: Initially, the like button functions properly. However, upon refreshing the page or navigating away and returning to the homepage, the like button mysterio ...

External CSS file unable to load background image as referenced

I am facing an issue with this code in my external CSS file as it doesn't seem to work at all. Strangely, when I move it internally, everything functions perfectly. Any thoughts on what could be causing this discrepancy? html { background-image:url(i ...

Encountering additional backslashes ("") in each slash within the JSON response received from Laravel AJAX

I have been working on my Laravel app and attempting to make an ajax call. However, I am encountering an issue where there is one extra slash being added, whether it's a backslash or a forward slash. Can someone please explain why this is happening an ...

React Fixed Footer Implementation against My Preferences

Here's an issue that I'm facing: https://i.stack.imgur.com/gtQqm.png The footer on my webpage is normally displayed at the bottom of the page. However, when the user performs certain actions that extend the size of the page: https://i.stack.im ...

Ways to verify if the CSS background-color is set to white?

I am looking for a solution: $('*').click(function() { if($(this).css("background-color") == "#ffffff") { $(this).css("background-color") == "#000000" } });​​​​ that will execute on click of a specific cla ...