The linear gradient shifts when the screen size is modified

My background features a linear gradient:

The issue arises when the screen size changes, as the gradient does not start at Point 0:

How can I ensure that the gradient always starts at point 0 regardless of the screen size? (Excluding mobile screens)

body #screen-background{
    
    background: linear-gradient(-5deg, #DFDFDD 10%, #3D4A6D 11%);

}

This is my desired outcome. If the screen size changes, it's okay for the angle to change but I just need the gradient to begin and end like this:

.linear-background{
background: linear-gradient(-5deg, #DFDFDD 10%, #3D4A6D 11%);
width: 200px;
height: 200px;
}
<html>
<div class="linear-background"></div>
</html>

Answer №1

Have you considered adding position:relative; to the .linear-background class in your CSS code? Here's an example:

.linear-background{
background: linear-gradient(-5deg, #DFDFDD 10%, #3D4A6D 11%);
height: 200px;
width: 200px;
}

Answer №2

Discovering clip paths was a game-changer I am amazed by how useful they are Much gratitude to @mxritz and @AHaworth for sharing

Visit Bennett Feely's Clippy website here

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

Issue with Framework7: Swiper slider link not functional

On one of the slides in my swiper slider, there is a link that redirects to a file named year.html Here is the link: <a href="year.html">Add by year, make & model</a> Source code for swiper slider: http://pastebin.com/ggN3TqgA Content ...

Using HTML strings in JavaScript code

I am currently working on a basic modal feature where I pass a string to be displayed as the content of the modal window. Here is a snippet of the script I am using: $("[id^='mod_']").click( function() { var line1 = $(this).attr("d ...

Creating a button that can automatically scroll to a specific table row

I have implemented code that fetches data from my database and displays it in a table format. The code snippet is shown below: <body> <?php include('navbar.php'); ?> <div class="container"> <h1 class="page-header text-ce ...

Having trouble with Vuex actions. Getting an error message that says "Failed to signInWithEmailAndPassword: The first argument "email" must be a valid string."

I recently started exploring Vuejs state management. I attempted to create a login system with Firebase using Vuex. However, I encountered the following error: signInWithEmailAndPassword failed: First argument "email" must be a valid string I'm havi ...

Troubleshooting a Minimum Width Problem in HTML and CSS

Having trouble with setting a minimum width for a specific section. When the browser size is smaller than the set minimum width, the background color/image defined by CSS does not expand beyond the window size. Essentially, when scrolling horizontally to v ...

Exploring different ways to customize the grid style in Angular 6

Here is the style I am working with: .main-panel{ height: 100%; display: grid; grid-template-rows: 4rem auto; grid-template-columns: 14rem auto; grid-template-areas: 'header header''sidebar body'; } I want to know how to cha ...

Techniques for Shortening Dates in JavaScript

How can I abbreviate a full date in JavaScript? For example, converting 15 September 2020 to 15 SEP 20. I have arrays of dates that need this formatting. ...

translateZ function fails to function properly on Firefox browser

I've been experimenting with using translateZ to hide a child element called "list" behind the parent element "div2. It works perfectly in Chrome, but unfortunately, it's not working correctly on Firefox. Can anyone provide some guidance or help ...

Unexpected outcome when mocking Vuex getters in unit testing

I've been delving into writing unit tests for VueJS components and have been utilizing this article as a guide for testing components that rely on the Vuex store. Let's take a closer look at the component in question: <!-- COMPONENT --> & ...

Remove links using the each() function in Javascript

My website is built on prestashop, and I have a dropdown menu with various clickable categories. However, I want to remove the links from the "Marques" and "Les Gammes" categories and only keep the text displayed. To achieve this, I am using the each() fun ...

Tips on resetting the position of a div after filtering out N other divs

Check out this code snippet. HTML Code: X.html <input type="text" id="search-criteria"/> <input type="button" id="search" value="search"/> <div class="col-sm-3"> <div class="misc"> <div class="box box-info"> ...

What could be causing the error message "The program 'vue' is not recognized as an internal or external command" to appear in VS Code?

As I delved into the world of Vue, I decided to set up vue cli in visual studio code using this command: npm install -g @vue/cli However, when attempting to create a new vue app with vue create ..., an error message pops up saying: "'vue' i ...

Creating tilted divs with dynamic height to perfectly fit the content

I'm struggling to incorporate this design into my webpage; I can't seem to get the right div's height to match the left div as depicted in the second image. Can someone offer some assistance? Additionally, when viewed on mobile, the squares ...

How can I show a tooltip when hovering over a tab using uib-tab?

Currently facing an issue with HTML/Bootstrap. My tabs are displayed using the uib-tabset directive on Angular Bootstrap (UI Bootstrap). I am trying to implement a tooltip that appears when hovering over a tab that is disabled. Does anyone know how I can a ...

Troubleshooting error in Vue project: "hasOwnProperty" property or method not supported by object in IE11

While working on a vue app with vue advanced webpack template, I didn't pay much attention to Internet Explorer compatibility. However, today when I tried running the app on IE browser, I encountered some strange errors. https://i.stack.imgur.com/1e6 ...

Ways to change the default blue dropdown color in the Chrome browser

When you click on the drop-down menu, a blue color appears when hovered over. I want it to be red instead, but for some reason, it's not working in Chrome browser. Here is the CSS class that I have used: option:checked { box-shadow: 0 0 10px 100p ...

What are some ways to remove scroll bars from an iframe?

I'm having trouble with scroll bars appearing in my iframe when inside a fancy box. I have tried everything to remove them without success. For example, you can view the issue here: http://jsfiddle.net/t4j3C/ No matter what I try, nothing seems to w ...

Input text being dynamically displayed in all input fields within a v-for loop

Attached is a snippet of code: <post v-for="post in posts" :post="post" :key="post.id"> <template v-slot:publishComment> <v-text-field v-model="message"></v-text-field> ...

Video on YouTube restarts upon hiding and revealing its container div

Is there a way to retain the progress and playback position of a YouTube video embedded within a div on a webpage? Currently, when I hide and then show the div using jQuery/CSS, the video reloads and starts from the beginning. Is there a solution to avoid ...

Using jQuery to implement conditional logic in HTML

Is there a way to exclude tags/variables in a jQuery HTML method? For example, if the company field is empty, it should not appear in the HTML. $('.modal-body').html(` <p><span style="font-weight:bold;">Name:< ...